API Reference
CustomLogger
Bases: Logger
Custom logger that supports a TRACE level and sets up logging with both console and file handlers.
Source code in src/decima/logger.py
76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 | |
setup_logging(folder, filename, level, class_length)
staticmethod
Set up logging with a handler that uses the custom LogFormatter and a file handler that writes logs in JSON format using the JsonFormatter.
| Parameters: |
|
|---|
Description
- This method configures the logging system to use a custom logger class (CustomLogger) and sets up two handlers: a console handler that formats logs with colors based on log levels, and
Source code in src/decima/logger.py
87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 | |
trace(msg, *args, **kwargs)
Log a message with severity 'TRACE'.
Source code in src/decima/logger.py
82 83 84 85 | |
JsonFormatter
Bases: Formatter
Log formatter that outputs logs in JSON format, including timestamp, level, name, message, and any extra data.
Source code in src/decima/logger.py
58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 | |
format(record)
Format the log record as a JSON string, including timestamp, level, name, message, and any extra data if provided.
Source code in src/decima/logger.py
61 62 63 64 65 66 67 68 69 70 71 72 73 | |
LogFormatter
Bases: Formatter
Log formatter that adds colors based on log levels.
Source code in src/decima/logger.py
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 46 47 48 49 50 51 52 53 54 55 | |
__init__(class_length)
Initialize the LogFormatter with a specified class name length for formatting.
| Parameters: |
|
|---|
Notes
- The formatter will apply different colors to the log output based on the log level (e.g., TRACE, DEBUG, INFO, WARNING, ERROR, CRITICAL).
- The log format includes the timestamp, log level, logger name (formatted with bold), and the log message.
Source code in src/decima/logger.py
11 12 13 14 15 16 17 18 19 20 21 22 23 | |
format(record)
Override the format method to apply color formatting based on log levels and truncate logger names if they exceed the specified class length.
Source code in src/decima/logger.py
40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 | |