aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--etc/default_settings.py2
-rw-r--r--wqflask/runserver.py34
-rw-r--r--wqflask/utility/Plot.py2
-rw-r--r--wqflask/utility/logger.py20
-rw-r--r--wqflask/utility/tools.py3
-rw-r--r--wqflask/wqflask/database.py6
6 files changed, 47 insertions, 20 deletions
diff --git a/etc/default_settings.py b/etc/default_settings.py
index 28fb40fc..58e37e18 100644
--- a/etc/default_settings.py
+++ b/etc/default_settings.py
@@ -36,7 +36,7 @@ SECRET_HMAC_CODE = '\x08\xdf\xfa\x93N\x80\xd9\\H@\\\x9f`\x98d^\xb4a;\xc6OM\x946a
# Behavioural settings (defaults) note that logger and log levels can
# be overridden at the module level
WEBSERVER_MODE = 'DEV' # Python webserver mode (DEBUG|DEV|PROD)
-LOGGING = 'WARNING' # Logger mode (DEBUG|INFO|WARNING|ERROR|CRITICAL)
+LOG_LEVEL = 'WARNING' # Logger mode (DEBUG|INFO|WARNING|ERROR|CRITICAL)
DEBUG_LOG_LEVEL = 1 # Debug log level (0-5)
LOG_SQL = False # Log SQL/backend calls
USE_REDIS = True # REDIS caching (note that redis will be phased out)
diff --git a/wqflask/runserver.py b/wqflask/runserver.py
index bc54130c..f40d8a48 100644
--- a/wqflask/runserver.py
+++ b/wqflask/runserver.py
@@ -22,16 +22,28 @@ from wqflask import app
print app.config
-import logging
-file_handler = logging.FileHandler(app.config['LOGFILE'])
-file_handler.setLevel(logging.DEBUG)
-app.logger.addHandler(file_handler)
-
from utility.tools import WEBSERVER_MODE
-app.run(host='0.0.0.0',
- port=app.config['SERVER_PORT'],
- debug=(WEBSERVER_MODE=='DEBUG'),
- use_debugger=(WEBSERVER_MODE=='DEBUG'),
- threaded=(WEBSERVER_MODE=='PROD'),
- use_reloader=True)
+if WEBSERVER_MODE == 'DEBUG':
+ app.run(host='0.0.0.0',
+ port=app.config['SERVER_PORT'],
+ debug=True,
+ use_debugger=True,
+ threaded=False,
+ use_reloader=True)
+elif WEBSERVER_MODE == 'DEV':
+ app.run(host='0.0.0.0',
+ port=app.config['SERVER_PORT'],
+ debug=False,
+ use_debugger=False,
+ threaded=False,
+ processes=0,
+ use_reloader=True)
+else: #production mode
+ app.run(host='0.0.0.0',
+ port=app.config['SERVER_PORT'],
+ debug=False,
+ use_debugger=False,
+ threaded=True,
+ processes=8,
+ use_reloader=True)
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']
diff --git a/wqflask/wqflask/database.py b/wqflask/wqflask/database.py
index 9d8425ad..f9c57d78 100644
--- a/wqflask/wqflask/database.py
+++ b/wqflask/wqflask/database.py
@@ -12,10 +12,8 @@ db_session = scoped_session(sessionmaker(autocommit=False,
Base = declarative_base()
Base.query = db_session.query_property()
-import logging
-logger = logging.getLogger(__name__ )
-logging.basicConfig(level=logging.INFO)
-
+import utility.logger
+logger = utility.logger.getLogger(__name__ )
def init_db():
# import all modules here that might define models so that