-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refine LoggerConfig and LoggerSettings
- Loading branch information
1 parent
7178db1
commit 42e02a1
Showing
2 changed files
with
32 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,14 @@ | ||
import os | ||
from pathlib import Path | ||
|
||
from pydantic_settings import BaseSettings | ||
|
||
|
||
class LoggerSettings(BaseSettings): | ||
LOG_FILE_PATH: Path = Path(os.environ.get('LOG_FILE_PATH', '/tmp/workers.log')) | ||
DEFAULT_LOG_LEVEL: str = os.environ.get('LOG_LEVEL', 'INFO').upper() | ||
DEFAULT_HANDLERS: list[str] = ['file'] # The root handler is used by default for logging. | ||
""" | ||
A class that defines logger settings, which can be overridden by environment variables. | ||
Defaults are provided if no environment variables are set. | ||
""" | ||
LOG_FILE_PATH: str = os.environ.get('LOG_FILE_PATH', '/tmp/workers.log') | ||
LOG_LEVEL: str = os.environ.get('LOG_LEVEL', 'INFO').upper() | ||
LOG_FORMAT_DEFAULT: str = '%(asctime)s | %(threadName)s | %(levelname)s | %(source)s | %(message)s' | ||
LOG_FORMAT_VERBOSE: str = '%(asctime)s | %(levelname)s | %(name)s | %(filename)s:%(lineno)d | %(message)s' |