From 53f2fca82af00184d5e411276121a596ab3654cc Mon Sep 17 00:00:00 2001 From: "Peter J. Holzer" Date: Sat, 10 Dec 2022 22:24:41 +0100 Subject: [PATCH] Make logging configurable --- app.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/app.py b/app.py index 6f4be95..2054e2a 100644 --- a/app.py +++ b/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: