API Reference
LogSettings
Bases: BaseModel
Settings for the loggers.
Attributes:
Name | Type | Description |
---|---|---|
console_level |
Optional[int]
|
The level to use for the console output. |
file_level |
Optional[int]
|
The level to use for the file output. |
file_path |
Optional[str]
|
The path where the log file should be created. Can contain the following placeholders:
If |
file_override |
Optional[bool]
|
Should the file be opened in overwrite mode or append mode? |
base |
Optional[str]
|
The base logger (used with |
others |
Dict[str, int]
|
Change the log levels for specific loggers. |
Source code in log2me/settings.py
setup_logging(stg, debug=False)
Sets up logging for the application.
If a log file is specified in the settings, the log file will be created and used. Otherwise, only the console will be used. The path of the log file can contain the following placeholders:
- %date%: The current date in the format YYYY-MM-DD.
- %time%: The current time in the format HH-MM-SS.
- %Y%: The current year.
- %M%: The current month.
- %D%: The current day.
- %H%: The current hour.
- %m%: The current minute.
- %s%: The current second.
- %ms%: The current microsecond.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
stg |
LogSettings
|
The settings object. |
required |
Returns:
Type | Description |
---|---|
Logger
|
The logger object. |
Source code in log2me/setup_log.py
Settings
LogSettings
Bases: BaseModel
Settings for the loggers.
Attributes:
Name | Type | Description |
---|---|---|
console_level |
Optional[int]
|
The level to use for the console output. |
file_level |
Optional[int]
|
The level to use for the file output. |
file_path |
Optional[str]
|
The path where the log file should be created. Can contain the following placeholders:
If |
file_override |
Optional[bool]
|
Should the file be opened in overwrite mode or append mode? |
base |
Optional[str]
|
The base logger (used with |
others |
Dict[str, int]
|
Change the log levels for specific loggers. |
Source code in log2me/settings.py
Setup
Sets up logging for the application.
If a log file is specified in the settings, the log file will be created and used. Otherwise, only the console will be used. The path of the log file can contain the following placeholders:
- %date%: The current date in the format YYYY-MM-DD.
- %time%: The current time in the format HH-MM-SS.
- %Y%: The current year.
- %M%: The current month.
- %D%: The current day.
- %H%: The current hour.
- %m%: The current minute.
- %s%: The current second.
- %ms%: The current microsecond.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
stg |
LogSettings
|
The settings object. |
required |
Returns:
Type | Description |
---|---|
Logger
|
The logger object. |