aboutsummaryrefslogtreecommitdiff
path: root/wqflask/utility
diff options
context:
space:
mode:
authorPjotr Prins2016-06-19 08:32:16 +0000
committerPjotr Prins2016-06-19 08:32:29 +0000
commit45bc57a19598c92fc4a64681bce629c1a74a03b8 (patch)
tree87d86da4282eef7cbf4589c679db91844949ef79 /wqflask/utility
parent489a361566e5e7c6352c2fbf6d37b029cfb0adb6 (diff)
downloadgenenetwork2-45bc57a19598c92fc4a64681bce629c1a74a03b8.tar.gz
logger: adding functionality for SQL
views.py: simplified code
Diffstat (limited to 'wqflask/utility')
-rw-r--r--wqflask/utility/logger.py19
1 files changed, 18 insertions, 1 deletions
diff --git a/wqflask/utility/logger.py b/wqflask/utility/logger.py
index 83b196a7..81202b05 100644
--- a/wqflask/utility/logger.py
+++ b/wqflask/utility/logger.py
@@ -31,28 +31,45 @@ import string
from utility.tools import LOG_LEVEL
class GNLogger:
- """A stub for multiple parameter logging"""
+ """A logger class with some additional functionality, such as
+ multiple parameter logging, SQL logging, timing, colors, and lazy
+ functions.
+
+ """
def __init__(self,name):
self.logger = logging.getLogger(name)
def setLevel(self,value):
+ """Set the undelying log level"""
self.logger.setLevel(value)
def debug(self,*args):
+ """Call logging.debug for multiple args"""
self.collect(self.logger.debug,*args)
def info(self,*args):
+ """Call logging.info for multiple args"""
self.collect(self.logger.info,*args)
def warning(self,*args):
+ """Call logging.warning for multiple args"""
self.collect(self.logger.warning,*args)
self.logger.warning(self.collect(*args))
def error(self,*args):
+ """Call logging.error for multiple args"""
self.collect(self.logger.error,*args)
+ def debugf(self,*args):
+ """Call logging.debug for multiple args"""
+ self.collect(self.logger.debug,*args)
+
+ def sql(self, sqlcommand, fun = None):
+ """Log SQL command, optionally invoking a timed fun"""
+
def collect(self,fun,*args):
+ """Collect arguments and use fun to output one by one"""
for a in args:
fun(a)