From 45bc57a19598c92fc4a64681bce629c1a74a03b8 Mon Sep 17 00:00:00 2001 From: Pjotr Prins Date: Sun, 19 Jun 2016 08:32:16 +0000 Subject: logger: adding functionality for SQL views.py: simplified code --- wqflask/utility/logger.py | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) (limited to 'wqflask/utility') 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) -- cgit v1.2.3