From 3a59631a4a95f4b4a1911e3a10912cdcbdf31200 Mon Sep 17 00:00:00 2001 From: Pjotr Prins Date: Sat, 18 Jun 2016 07:36:14 +0000 Subject: Logging: behaviours --- wqflask/utility/Plot.py | 2 -- wqflask/utility/logger.py | 20 +++++++++++++++++++- wqflask/utility/tools.py | 3 ++- 3 files changed, 21 insertions(+), 4 deletions(-) (limited to 'wqflask/utility') diff --git a/wqflask/utility/Plot.py b/wqflask/utility/Plot.py index 4752de57..372e0ac5 100644 --- a/wqflask/utility/Plot.py +++ b/wqflask/utility/Plot.py @@ -29,8 +29,6 @@ from __future__ import print_function import piddle as pid from pprint import pformat as pf -print("Lysol") - from math import * import random import sys, os diff --git a/wqflask/utility/logger.py b/wqflask/utility/logger.py index 85a64438..6f9d0f96 100644 --- a/wqflask/utility/logger.py +++ b/wqflask/utility/logger.py @@ -5,4 +5,22 @@ # settings for log levels (global and by module) and (potentially) # offers some fine grained log levels for the standard levels. # -# Global settings (defined in default_settings.py). +# All behaviour is defined here. Global settings (defined in +# default_settings.py). + +import logging + +from utility.tools import LOG_LEVEL + +print("Set global log level to "+LOG_LEVEL) + +log_level = getattr(logging, LOG_LEVEL.upper()) +logging.basicConfig(level=log_level) + +# Get the module logger. You can override log levels at the +# module level +def getLogger(name, level = None): + logger = logging.getLogger(name) + if level: + logger.setLevel(level) + return logger diff --git a/wqflask/utility/tools.py b/wqflask/utility/tools.py index 958f7b15..08495c2f 100644 --- a/wqflask/utility/tools.py +++ b/wqflask/utility/tools.py @@ -5,6 +5,7 @@ import os import sys from wqflask import app +# Use the standard logger here to avoid a circular dependency import logging logger = logging.getLogger(__name__ ) logging.basicConfig(level=logging.INFO) @@ -135,7 +136,7 @@ def tempdir(): # Cached values WEBSERVER_MODE = get_setting('WEBSERVER_MODE') -LOGGING = get_setting('LOGGING') +LOG_LEVEL = get_setting('LOG_LEVEL') DEBUG_LOG_LEVEL = get_setting('DEBUG_LOG_LEVEL') LOG_SQL = get_setting('LOG_SQL') in [True,'TRUE','True','true'] USE_REDIS = get_setting('USE_REDIS') in [True,'TRUE','True','true'] -- cgit v1.2.3