logger
EnsysLogger
¶
Handles creation and management of a logger instance with specific configurations.
The EnsysLogger
class provides functionality to create a logger instance tied to
a specific name, logging level, and a file to store log outputs. Logs are formatted
to include a timestamp and message, ensuring traceability and readability in UTF-8
encoded files. This class supports logging at various severity levels including debug,
info, warning, error, and critical.
Attributes:
Name | Type | Description |
---|---|---|
logger |
Internal logger instance used to handle logging messages. |
Source code in backend/app/logger.py
__init__(name, filename, level=logging.INFO)
¶
Initializes a logger instance with a given configuration. The logger is associated with a specific name, writes logs to a specified file, and operates at the defined logging level. The logging messages are encoded in UTF-8 format and include a timestamp followed by the log message.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
name
|
str
|
The name associated with the logger instance. |
required |
filename
|
str
|
The name of the file where logs will be written. |
required |
level
|
int, optional
|
The logging level for the logger. Defaults to logging.INFO. |
INFO
|
Source code in backend/app/logger.py
critical(msg)
¶
Logs a critical severity message prefixed with the custom identifier "[C----]"
Parameters:
Name | Type | Description | Default |
---|---|---|---|
msg
|
str
|
The message to log. It provides the content describing the critical issue or context. |
required |
Returns:
Type | Description |
---|---|
None |
Source code in backend/app/logger.py
debug(msg)
¶
Logs a debug message prefixed with the custom identifier "[----D]"
Parameters:
Name | Type | Description | Default |
---|---|---|---|
msg
|
str
|
The message to be logged. |
required |
Returns:
Type | Description |
---|---|
None |
error(msg)
¶
Logs an error message prefixed with the custom identifier "[-E---]".
Parameters:
Name | Type | Description | Default |
---|---|---|---|
msg
|
str
|
The message string to be logged. |
required |
Returns:
Type | Description |
---|---|
None |
info(msg)
¶
Logs an informational message prefixed with the custom identifier "[---I-]"
Parameters:
Name | Type | Description | Default |
---|---|---|---|
msg
|
str
|
The message to log. |
required |
Returns:
Type | Description |
---|---|
None |
warn(msg)
¶
Logs a warning message prefixed with the custom identifier "[--W--]".
Parameters:
Name | Type | Description | Default |
---|---|---|---|
msg
|
str
|
The message to be logged as a warning. |
required |
Returns:
Type | Description |
---|---|
None |