diff options
author | Pjotr Prins | 2016-06-23 08:29:25 +0000 |
---|---|---|
committer | Pjotr Prins | 2016-06-23 08:29:25 +0000 |
commit | 1665de1e732682fa2e3a5d37b5bece325158eeeb (patch) | |
tree | 9edf54ce2c3959f612ba14758208c03cfe83ba1b | |
parent | 1c20ebfa0a314bd3cb8f5698e976a22423c9f522 (diff) | |
download | genenetwork2-1665de1e732682fa2e3a5d37b5bece325158eeeb.tar.gz |
Logger: prettify
-rw-r--r-- | wqflask/utility/logger.py | 29 | ||||
-rw-r--r-- | wqflask/wqflask/views.py | 2 |
2 files changed, 24 insertions, 7 deletions
diff --git a/wqflask/utility/logger.py b/wqflask/utility/logger.py index 556a265c..a2ae1f1a 100644 --- a/wqflask/utility/logger.py +++ b/wqflask/utility/logger.py @@ -29,8 +29,11 @@ import logging import string from inspect import isfunction +from pprint import pformat as pf + from utility.tools import LOG_LEVEL, LOG_SQL, LOG_FORMAT + class GNLogger: """A logger class with some additional functionality, such as multiple parameter logging, SQL logging, timing, colors, and lazy @@ -85,17 +88,31 @@ class GNLogger: return result def collect(self,fun,*args): - """Collect arguments and use fun to output one by one""" + """Collect arguments and use fun to output""" + out = "" for a in args: - fun(a) + if len(out)>0: + out += ": " + if isinstance(a, str): + out = out + a + else: + out = out + pf(a,width=160) + fun(out) def collectf(self,fun,*args): """Collect arguments and use fun to output one by one""" + out = "" for a in args: - if isfunction(a): - fun(a()) - else: - fun(a) + if len(out)>0: + out += ": " + if isfunction(a): + out += a() + else: + if isinstance(a, str): + out = out + a + else: + out = out + pf(a,width=160) + fun(out) # Get the module logger. You can override log levels at the # module level diff --git a/wqflask/wqflask/views.py b/wqflask/wqflask/views.py index 83aa7d84..ac45815b 100644 --- a/wqflask/wqflask/views.py +++ b/wqflask/wqflask/views.py @@ -140,7 +140,7 @@ def search_page(): the_search = search_results.SearchResultPage(request.args) result = the_search.__dict__ - logger.debugf("result: ", lambda: pf(result)) + logger.debugf("result", result) if USE_REDIS: Redis.set(key, pickle.dumps(result, pickle.HIGHEST_PROTOCOL)) |