-
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlogging_config.py
More file actions
45 lines (33 loc) · 1.06 KB
/
logging_config.py
File metadata and controls
45 lines (33 loc) · 1.06 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
# -*- coding: utf-8 -*-
"""
Centralized logging configuration for the Stackademy application.
"""
import logging
import sys
from app.settings import LOGGING_LEVEL
def setup_logging(level: int = LOGGING_LEVEL) -> logging.Logger:
"""
Configure logging for the application.
Args:
level: The logging level (default: logging.INFO)
Returns:
Logger instance for the calling module
"""
# Only configure if not already configured
if not logging.getLogger().handlers:
logging.basicConfig(
level=level,
format="%(asctime)s - %(name)s - %(levelname)s - %(message)s",
handlers=[logging.StreamHandler(sys.stdout)], # This logs to console
)
logging.getLogger("httpx").setLevel(logging.WARNING)
return logging.getLogger(__name__)
def get_logger(name: str) -> logging.Logger:
"""
Get a logger instance for the specified module.
Args:
name: The name of the module (usually __name__)
Returns:
Logger instance
"""
return logging.getLogger(name)