aboutsummaryrefslogtreecommitdiff
path: root/wqflask/utility
diff options
context:
space:
mode:
authorPjotr Prins2016-06-19 08:50:55 +0000
committerPjotr Prins2016-06-19 08:50:55 +0000
commit2214650621ee57b4c427bf8b5cab1128eb06db93 (patch)
treeb1c29a7e9b99ced8d496497a6c9d8bcfdbc1932e /wqflask/utility
parent45bc57a19598c92fc4a64681bce629c1a74a03b8 (diff)
downloadgenenetwork2-2214650621ee57b4c427bf8b5cab1128eb06db93.tar.gz
Logger: started logging SQL
Diffstat (limited to 'wqflask/utility')
-rw-r--r--wqflask/utility/logger.py15
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):