Make logging configurable
This commit is contained in:
parent
93ec187805
commit
53f2fca82a
8
app.py
8
app.py
|
@ -1,14 +1,18 @@
|
|||
import logging
|
||||
import logging.config
|
||||
import psycopg2
|
||||
import psycopg2.extras
|
||||
|
||||
from flask import Flask, render_template, g, redirect, request, url_for
|
||||
|
||||
logging.basicConfig(format="%(asctime)s %(levelname)s %(name)s %(lineno)d | %(message)s", level=logging.DEBUG)
|
||||
import config
|
||||
|
||||
logging.config.dictConfig(config.logging)
|
||||
|
||||
app = Flask(__name__)
|
||||
|
||||
log = logging.getLogger(__name__)
|
||||
log.info("starting")
|
||||
|
||||
@app.route("/")
|
||||
def home():
|
||||
|
@ -57,7 +61,7 @@ def get_db():
|
|||
|
||||
@app.teardown_appcontext
|
||||
def teardown_db(exception):
|
||||
log.info("in teardown_db: exception = %s", exception)
|
||||
log.debug("in teardown_db: exception = %s", exception)
|
||||
db = g.pop('db', None)
|
||||
if db is not None:
|
||||
if not exception:
|
||||
|
|
Loading…
Reference in New Issue