about summary refs log tree commit diff
path: root/wqflask
diff options
context:
space:
mode:
Diffstat (limited to 'wqflask')
-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
5 files changed, 46 insertions, 19 deletions
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