diff options
-rw-r--r-- | etc/default_settings.py | 2 | ||||
-rw-r--r-- | wqflask/base/data_set.py | 3 | ||||
-rw-r--r-- | wqflask/utility/logger.py | 16 |
3 files changed, 17 insertions, 4 deletions
diff --git a/etc/default_settings.py b/etc/default_settings.py index 547478df..d8e57f38 100644 --- a/etc/default_settings.py +++ b/etc/default_settings.py @@ -42,7 +42,7 @@ WEBSERVER_BRANDING = None # Set the branding (nyi) WEBSERVER_DEPLOY = None # Deployment specifics (nyi) LOG_LEVEL = 'WARNING' # Logger mode (DEBUG|INFO|WARNING|ERROR|CRITICAL) -LOG_LEVEL_DEBUG = '0' # Debug log level (0-5, 0 = show all) +LOG_LEVEL_DEBUG = '0' # logger.debugf log level (0-5, 5 = show all) LOG_SQL = 'False' # Log SQL/backend and GN_SERVER calls LOG_SQLALCHEMY = 'False' LOG_BENCH = True # Log bench marks diff --git a/wqflask/base/data_set.py b/wqflask/base/data_set.py index 8bd5bfb9..fddfce58 100644 --- a/wqflask/base/data_set.py +++ b/wqflask/base/data_set.py @@ -107,7 +107,8 @@ Publish or ProbeSet. E.g. else: new_type = "ProbeSet" self.datasets[short_dataset_name] = new_type - logger.debug("datasets",self.datasets) + # Set LOG_LEVEL_DEBUG=5 to see the following: + logger.debugf(5,"datasets",self.datasets) def __call__(self, name): return self.datasets[name] diff --git a/wqflask/utility/logger.py b/wqflask/utility/logger.py index b873e16f..bacb0aa4 100644 --- a/wqflask/utility/logger.py +++ b/wqflask/utility/logger.py @@ -50,11 +50,20 @@ class GNLogger: self.logger.setLevel(value) def debug(self,*args): + """Call logging.debug for multiple args. Use (lazy) debugf and +level=num to filter on LOG_LEVEL_DEBUG. + + """ + self.collect(self.logger.debug,*args) + + def debug20(self,*args): """Call logging.debug for multiple args. Use level=num to filter on LOG_LEVEL_DEBUG (NYI). """ - self.collect(self.logger.debug,*args) + if level <= LOG_LEVEL_DEBUG: + if self.logger.getEffectiveLevel() < 20: + self.collect(self.logger.debug,*args) def info(self,*args): """Call logging.info for multiple args""" @@ -79,7 +88,10 @@ LOG_LEVEL_DEBUG (NYI). self.collectf(self.logger.debug,*args) def debugf(self,level=0,*args): - """Call logging.debug for multiple args lazily""" + """Call logging.debug for multiple args lazily and handle + LOG_LEVEL_DEBUG correctly + + """ # only evaluate function when logging if level <= LOG_LEVEL_DEBUG: if self.logger.getEffectiveLevel() < 20: |