Skip to content

Commit 88f5b76

Browse files
committed
change logging output
1 parent 399adc3 commit 88f5b76

File tree

1 file changed

+18
-15
lines changed

1 file changed

+18
-15
lines changed

utils/custom_logger.py

Lines changed: 18 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -3,28 +3,31 @@
33
import json
44
from pathlib import Path
55
import sys
6+
from datetime import datetime
67

78
LOG_LEVEL = 'DEBUG'
89
discord_logger = None
910

1011
def create_logger():
11-
"""
12-
Creates and configures a logger with specified log level and formats for console and file logging.
13-
14-
Args:
15-
None
16-
17-
Returns:
18-
None
19-
20-
Raises:
21-
None
22-
"""
2312
logs_path = Path('logs')
2413
logs_path.mkdir(exist_ok=True)
25-
log_format = "<green>{time:YYYY-MM-DD HH:mm:ss}</green> | <level>{level}</level> | <level>{message}</level>" if LOG_LEVEL != 'DEBUG' else "<green>{time:YYYY-MM-DD HH:mm:ss}</green> | <level>{level}</level> | <red>{file}</red> | <yellow>{function}</yellow> | <level>{message}</level>"
26-
logger.add(sys.stdout, level=LOG_LEVEL, colorize=True, format=log_format)
27-
logger.add(logs_path / 'retrocord.log', level=LOG_LEVEL, colorize=True, format=log_format)
14+
today = datetime.now().strftime("%Y-%m-%d")
15+
16+
# Correct format string - ANSI codes REMOVED:
17+
log_format = "<green>{time:YYYY-MM-DD HH:mm:ss}</green> | <level>{level}</level> | <cyan>{file}</cyan> | <yellow>{function}</yellow> | <magenta>{module}</magenta> | <level>{message}</level>" # % removed
18+
19+
logger.add(
20+
logs_path / f"{today}-trophycord.log",
21+
level=LOG_LEVEL,
22+
format=log_format,
23+
# colorize=True, # Add this back if you want loguru to handle colors. Remove for plain text
24+
)
25+
logger.add(
26+
sys.stdout,
27+
level=LOG_LEVEL,
28+
format=log_format,
29+
colorize=True, # Colorize for console output
30+
)
2831

2932
def switch_logger():
3033
"""

0 commit comments

Comments
 (0)