From 968e8b5976a5d730d3aa4267a246cfedf9cf3398 Mon Sep 17 00:00:00 2001 From: Alexis Lahouze Date: Fri, 10 Jul 2015 14:59:37 +0200 Subject: [PATCH] Add debugging. --- accountant/__init__.py | 12 ++++++++++++ accountant/config.py.dist | 4 +++- 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/accountant/__init__.py b/accountant/__init__.py index c2d1872..d1f2a11 100644 --- a/accountant/__init__.py +++ b/accountant/__init__.py @@ -16,11 +16,21 @@ """ from contextlib import contextmanager +import logging + from flask import Flask from flask.ext.sqlalchemy import SQLAlchemy from . import config +logging.basicConfig() + +if config.debug: + logging.getLogger().setLevel(logging.DEBUG) + logging.getLogger('sqlalchemy.engine').setLevel(logging.INFO) +else: + logging.getLogger().setLevel(logging.INFO) + # The app app = Flask(__name__, static_folder=None) @@ -29,6 +39,8 @@ app.config['SQLALCHEMY_RECORD_QUERIES'] = config.debug app.config['WTF_CSRF_ENABLED'] = False app.config['SECRET_KEY'] = 'my_secret_key' +app.debug = config.debug + db = SQLAlchemy(app) diff --git a/accountant/config.py.dist b/accountant/config.py.dist index 1dafb97..287c7ec 100644 --- a/accountant/config.py.dist +++ b/accountant/config.py.dist @@ -1,3 +1,5 @@ - +# Daabase connection URI db_uri='postgresql://accountant:accountant@localhost/accountant' + +# Debug debug=True