diff options
author | Pjotr Prins | 2016-06-19 16:03:26 +0000 |
---|---|---|
committer | Pjotr Prins | 2016-06-19 16:03:26 +0000 |
commit | aae827674cdbe46c7f1ce5d2246bf485a24dbbb3 (patch) | |
tree | f6a106c6544c8d68aae29b8a2e3e1ceb3de648b3 /wqflask/utility/logger.py | |
parent | 2214650621ee57b4c427bf8b5cab1128eb06db93 (diff) | |
download | genenetwork2-aae827674cdbe46c7f1ce5d2246bf485a24dbbb3.tar.gz |
gn_server: SQL handling
Diffstat (limited to 'wqflask/utility/logger.py')
-rw-r--r-- | wqflask/utility/logger.py | 16 |
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""" |