aboutsummaryrefslogtreecommitdiff
path: root/wqflask/utility/logger.py
diff options
context:
space:
mode:
Diffstat (limited to 'wqflask/utility/logger.py')
-rw-r--r--wqflask/utility/logger.py16
1 files changed, 13 insertions, 3 deletions
diff --git a/wqflask/utility/logger.py b/wqflask/utility/logger.py
index bc0578c9..0d374f1a 100644
--- a/wqflask/utility/logger.py
+++ b/wqflask/utility/logger.py
@@ -62,14 +62,24 @@ class GNLogger:
"""Call logging.error for multiple args"""
self.collect(self.logger.error,*args)
+ def infof(self,*args):
+ """Call logging.info for multiple args lazily"""
+ # only evaluate function when logging
+ if self.logger.getEffectiveLevel() < 30:
+ self.collectf(self.logger.debug,*args)
+
def debugf(self,*args):
"""Call logging.debug for multiple args lazily"""
- if self.logger.getEffectiveLevel() <= 10:
- self.debug("Calling debug function!")
+ # only evaluate function when logging
+ if self.logger.getEffectiveLevel() < 20:
self.collectf(self.logger.debug,*args)
- def sql(self, sqlcommand, fun = None):
+ def sql(self, description, sqlcommand, fun = None):
"""Log SQL command, optionally invoking a timed fun"""
+ self.info(description,sqlcommand)
+ if fun:
+ self.info("Invoking function")
+ return fun(sqlcommand)
def collect(self,fun,*args):
"""Collect arguments and use fun to output one by one"""