From 1a22f2b5dedd3a685bb2869f1b51f590eca36c5a Mon Sep 17 00:00:00 2001 From: Frederick Muriuki Muriithi Date: Mon, 5 Jun 2023 06:16:28 +0300 Subject: Logging: Get user information. --- gn3/app.py | 9 ++++++--- gn3/auth/db.py | 2 +- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/gn3/app.py b/gn3/app.py index b55b6ff..ffde223 100644 --- a/gn3/app.py +++ b/gn3/app.py @@ -1,6 +1,8 @@ """Entry point from spinning up flask""" import os import sys +import logging +import getpass from typing import Dict from typing import Union @@ -44,10 +46,11 @@ def create_app(config: Union[Dict, str, None] = None) -> Flask: elif config.endswith(".py"): app.config.from_pyfile(config) - # DO NOT log anything before this point setup_app_handlers(app) - app.logger.info(f"Guix Profile: {os.environ.get('GUIX_PROFILE')}.") - app.logger.info(f"Python Executable: '{sys.executable}'.") + # DO NOT log anything before this point + logging.info("Guix Profile: '%s'." % (os.environ.get("GUIX_PROFILE"),)) + logging.info("Python Executable: '%s'." % sys.executable) + logging.info("Effective User: '%s'." % getpass.getuser()) CORS( app, diff --git a/gn3/auth/db.py b/gn3/auth/db.py index 9d5463f..7c20bf7 100644 --- a/gn3/auth/db.py +++ b/gn3/auth/db.py @@ -48,7 +48,7 @@ class DbCursor(Protocol): @contextlib.contextmanager def connection(db_path: str, row_factory: Callable = sqlite3.Row) -> Iterator[DbConnection]: """Create the connection to the auth database.""" - logging.debug(f"SQLite3 DB Path: '{db_path}'.") + logging.debug("SQLite3 DB Path: '%s'." % (db_path,)) conn = sqlite3.connect(db_path) conn.row_factory = row_factory conn.set_trace_callback(logging.debug) -- cgit v1.2.3