From 6750c291dba1c0b1c93a321b91fd0f0464bfde80 Mon Sep 17 00:00:00 2001 From: David Allada Date: Sun, 23 Mar 2025 16:49:58 +0000 Subject: [PATCH 1/5] Add file based logging in addition to the normal console logs --- common/logger.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/common/logger.py b/common/logger.py index 184b49d..c03a210 100644 --- a/common/logger.py +++ b/common/logger.py @@ -115,3 +115,13 @@ def setup_logger(): format=_log_formatter, colorize=True, ) + + # Add file logging + _ = logger.add( + "/var/log/tabbyapi/{time}.log", # This will create the file in the project root + level=LOG_LEVEL, + format="{time:YYYY-MM-DD HH:mm:ss.SSS} | {level: <8} | {message}", + rotation="20 MB", # Rotate file when it reaches 10MB + retention="1 week", # Keep logs for 1 week + compression="zip", # Compress rotated logs + ) From 0256d3b2a201c975b4d8cc45150117a07217a79d Mon Sep 17 00:00:00 2001 From: David Allada Date: Sun, 23 Mar 2025 16:51:47 +0000 Subject: [PATCH 2/5] Fix the comment from 10MB to 20MB --- common/logger.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/common/logger.py b/common/logger.py index c03a210..b4940a4 100644 --- a/common/logger.py +++ b/common/logger.py @@ -118,10 +118,10 @@ def setup_logger(): # Add file logging _ = logger.add( - "/var/log/tabbyapi/{time}.log", # This will create the file in the project root + "/var/log/tabbyapi/{time}.log", level=LOG_LEVEL, format="{time:YYYY-MM-DD HH:mm:ss.SSS} | {level: <8} | {message}", - rotation="20 MB", # Rotate file when it reaches 10MB + rotation="20 MB", # Rotate file when it reaches 20MB retention="1 week", # Keep logs for 1 week compression="zip", # Compress rotated logs ) From bcd3413628894e7cba8d85d06caadb63524e45c8 Mon Sep 17 00:00:00 2001 From: David Allada Date: Sun, 23 Mar 2025 17:02:52 +0000 Subject: [PATCH 3/5] Try to fix ruff format --- common/logger.py | 1 - 1 file changed, 1 deletion(-) diff --git a/common/logger.py b/common/logger.py index b4940a4..92f79a8 100644 --- a/common/logger.py +++ b/common/logger.py @@ -115,7 +115,6 @@ def setup_logger(): format=_log_formatter, colorize=True, ) - # Add file logging _ = logger.add( "/var/log/tabbyapi/{time}.log", From d31d17e5a20debf109199a978a915cc20866051e Mon Sep 17 00:00:00 2001 From: David Allada Date: Sun, 23 Mar 2025 17:04:09 +0000 Subject: [PATCH 4/5] Trigger ruff formatting --- common/logger.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/common/logger.py b/common/logger.py index 92f79a8..448b653 100644 --- a/common/logger.py +++ b/common/logger.py @@ -122,5 +122,5 @@ def setup_logger(): format="{time:YYYY-MM-DD HH:mm:ss.SSS} | {level: <8} | {message}", rotation="20 MB", # Rotate file when it reaches 20MB retention="1 week", # Keep logs for 1 week - compression="zip", # Compress rotated logs + compression="zip", # Compress rotated log ) From bc1bef33243c0a4440141d99e4daaf8a5c30ee7a Mon Sep 17 00:00:00 2001 From: David Allada Date: Tue, 22 Apr 2025 21:14:45 -0400 Subject: [PATCH 5/5] FIx logs path --- common/logger.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/common/logger.py b/common/logger.py index 448b653..ec576e3 100644 --- a/common/logger.py +++ b/common/logger.py @@ -9,12 +9,12 @@ from loguru import logger from rich.console import Console from rich.markup import escape from rich.progress import ( - Progress, - TextColumn, BarColumn, - TimeRemainingColumn, - TaskProgressColumn, MofNCompleteColumn, + Progress, + TaskProgressColumn, + TextColumn, + TimeRemainingColumn, ) from common.utils import unwrap @@ -116,8 +116,8 @@ def setup_logger(): colorize=True, ) # Add file logging - _ = logger.add( - "/var/log/tabbyapi/{time}.log", + logger.add( + "logs/{time}.log", level=LOG_LEVEL, format="{time:YYYY-MM-DD HH:mm:ss.SSS} | {level: <8} | {message}", rotation="20 MB", # Rotate file when it reaches 20MB