Make logging configurable

This commit is contained in:
Peter J. Holzer 2022-12-10 22:24:41 +01:00
parent 93ec187805
commit 53f2fca82a
1 changed files with 6 additions and 2 deletions

8
app.py
View File

@ -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: