diff options
Diffstat (limited to 'wqflask/utility/logger.py')
-rw-r--r-- | wqflask/utility/logger.py | 15 |
1 files changed, 13 insertions, 2 deletions
diff --git a/wqflask/utility/logger.py b/wqflask/utility/logger.py index 81202b05..bc0578c9 100644 --- a/wqflask/utility/logger.py +++ b/wqflask/utility/logger.py @@ -28,6 +28,7 @@ import logging import string +from inspect import isfunction from utility.tools import LOG_LEVEL class GNLogger: @@ -62,8 +63,10 @@ class GNLogger: self.collect(self.logger.error,*args) def debugf(self,*args): - """Call logging.debug for multiple args""" - self.collect(self.logger.debug,*args) + """Call logging.debug for multiple args lazily""" + if self.logger.getEffectiveLevel() <= 10: + self.debug("Calling debug function!") + self.collectf(self.logger.debug,*args) def sql(self, sqlcommand, fun = None): """Log SQL command, optionally invoking a timed fun""" @@ -73,6 +76,14 @@ class GNLogger: for a in args: fun(a) + def collectf(self,fun,*args): + """Collect arguments and use fun to output one by one""" + for a in args: + if isfunction(a): + fun(a()) + else: + fun(a) + # Get the module logger. You can override log levels at the # module level def getLogger(name, level = None): |