From d13ea1f33620fea149b0a0a8ab68c6353b5f6e38 Mon Sep 17 00:00:00 2001 From: Bakar Tavadze Date: Thu, 16 May 2024 15:57:46 +0400 Subject: [PATCH 1/2] Include timestamp, logger name and level name in file logs (along with the already present message). --- backend/app/lifespan.py | 3 --- backend/log_config.json | 3 ++- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/backend/app/lifespan.py b/backend/app/lifespan.py index e9062d59..8ba44cb7 100644 --- a/backend/app/lifespan.py +++ b/backend/app/lifespan.py @@ -36,10 +36,7 @@ async def lifespan(app: FastAPI): structlog.configure( processors=[ structlog.stdlib.filter_by_level, - structlog.stdlib.add_logger_name, - structlog.stdlib.add_log_level, structlog.stdlib.PositionalArgumentsFormatter(), - structlog.processors.TimeStamper(fmt="iso"), structlog.processors.StackInfoRenderer(), structlog.processors.format_exc_info, structlog.processors.UnicodeDecoder(), diff --git a/backend/log_config.json b/backend/log_config.json index 1f6bd1c1..a526a021 100644 --- a/backend/log_config.json +++ b/backend/log_config.json @@ -11,7 +11,8 @@ "fmt": "%(asctime)s - %(name)s - %(levelprefix)s %(client_addr)s - \"%(request_line)s\" %(status_code)s" }, "json": { - "()": "pythonjsonlogger.jsonlogger.JsonFormatter" + "()": "pythonjsonlogger.jsonlogger.JsonFormatter", + "fmt": "%(asctime)s - %(name)s - %(levelname)s %(message)s" } }, "handlers": { From 5635a2d70c2d4e1f91f2d203981cf58e5ac98c1d Mon Sep 17 00:00:00 2001 From: Bakar Tavadze Date: Thu, 16 May 2024 15:58:12 +0400 Subject: [PATCH 2/2] Display exceptions on the terminal. --- backend/app/lifespan.py | 1 - 1 file changed, 1 deletion(-) diff --git a/backend/app/lifespan.py b/backend/app/lifespan.py index 8ba44cb7..9fd47fd2 100644 --- a/backend/app/lifespan.py +++ b/backend/app/lifespan.py @@ -38,7 +38,6 @@ async def lifespan(app: FastAPI): structlog.stdlib.filter_by_level, structlog.stdlib.PositionalArgumentsFormatter(), structlog.processors.StackInfoRenderer(), - structlog.processors.format_exc_info, structlog.processors.UnicodeDecoder(), structlog.stdlib.render_to_log_kwargs, ],