diff options
author | Pjotr Prins | 2016-06-18 06:57:45 +0000 |
---|---|---|
committer | Pjotr Prins | 2016-06-18 06:57:45 +0000 |
commit | c93dfd2a6343690fdcfcb4b5dcb231f0ee4dc8fd (patch) | |
tree | 3d9c160041e38f90684eae92738c150618cb7775 /wqflask | |
parent | e9275a0eae086c3122d54e7207a4d872bdb0706c (diff) | |
download | genenetwork2-c93dfd2a6343690fdcfcb4b5dcb231f0ee4dc8fd.tar.gz |
Logger: improving output
Diffstat (limited to 'wqflask')
-rw-r--r-- | wqflask/runserver.py | 11 | ||||
-rw-r--r-- | wqflask/utility/tools.py | 2 | ||||
-rw-r--r-- | wqflask/wqflask/__init__.py | 9 | ||||
-rw-r--r-- | wqflask/wqflask/database.py | 15 |
4 files changed, 22 insertions, 15 deletions
diff --git a/wqflask/runserver.py b/wqflask/runserver.py index e4392b3f..bc54130c 100644 --- a/wqflask/runserver.py +++ b/wqflask/runserver.py @@ -1,5 +1,7 @@ from wqflask import app +# Start the webserver with ./bin/genenetwork2 +# # Please note, running with host set externally below combined with debug mode # is a big security no-no # Unless you have a firewall setup @@ -25,12 +27,11 @@ file_handler = logging.FileHandler(app.config['LOGFILE']) file_handler.setLevel(logging.DEBUG) app.logger.addHandler(file_handler) -# import logging_tree -# logging_tree.printout() +from utility.tools import WEBSERVER_MODE app.run(host='0.0.0.0', port=app.config['SERVER_PORT'], - debug=True, - use_debugger=True, - threaded=True, + debug=(WEBSERVER_MODE=='DEBUG'), + use_debugger=(WEBSERVER_MODE=='DEBUG'), + threaded=(WEBSERVER_MODE=='PROD'), use_reloader=True) diff --git a/wqflask/utility/tools.py b/wqflask/utility/tools.py index d43e2132..958f7b15 100644 --- a/wqflask/utility/tools.py +++ b/wqflask/utility/tools.py @@ -3,9 +3,9 @@ import os import sys -import logging from wqflask import app +import logging logger = logging.getLogger(__name__ ) logging.basicConfig(level=logging.INFO) diff --git a/wqflask/wqflask/__init__.py b/wqflask/wqflask/__init__.py index a26de39b..af271d02 100644 --- a/wqflask/wqflask/__init__.py +++ b/wqflask/wqflask/__init__.py @@ -6,12 +6,19 @@ import jinja2 from flask import Flask from utility import formatting +import logging +logger = logging.getLogger(__name__ ) +logging.basicConfig(level=logging.INFO) + app = Flask(__name__) app.config.from_object('cfg.default_settings') # Get the defaults from cfg.default_settings app.config.from_envvar('WQFLASK_SETTINGS') # See http://flask.pocoo.org/docs/config/#configuring-from-files -print("Current application configuration:", app.config) +logger.debug("System path is") +logger.debug(sys.path) +logger.debug("App.config is") +logger.debug(app.config) app.jinja_env.globals.update( undefined = jinja2.StrictUndefined, diff --git a/wqflask/wqflask/database.py b/wqflask/wqflask/database.py index 22c96a49..9d8425ad 100644 --- a/wqflask/wqflask/database.py +++ b/wqflask/wqflask/database.py @@ -1,7 +1,6 @@ from sqlalchemy import create_engine from sqlalchemy.orm import scoped_session, sessionmaker from sqlalchemy.ext.declarative import declarative_base - from wqflask import app #engine = create_engine('sqlite:////tmp/test.db', convert_unicode=True) @@ -13,10 +12,10 @@ db_session = scoped_session(sessionmaker(autocommit=False, Base = declarative_base() Base.query = db_session.query_property() -#import logging -# -#logging.basicConfig() -#logging.getLogger('sqlalchemy.engine').setLevel(logging.INFO) +import logging +logger = logging.getLogger(__name__ ) +logging.basicConfig(level=logging.INFO) + def init_db(): # import all modules here that might define models so that @@ -24,9 +23,9 @@ def init_db(): # you will have to import them first before calling init_db() #import yourapplication.models import wqflask.model - print("database.py: Creating all model metadata..") + logger.debug("database.py: Creating all model metadata..") Base.metadata.create_all(bind=engine) - print("database.py: Done creating all model metadata...") - print("Point your browser at http://localhost:5003/") + logger.info("database.py: Done creating all model metadata...") + logger.info("Point your browser at http://localhost:5003/") init_db() |