gc_batch.logger
Logger
A basic Python logger class that provides easy-to-use logging functionality.
Features: - Multiple log levels (DEBUG, INFO, WARNING, ERROR, CRITICAL) - Console and file output - Customizable log format - Automatic log file rotation
Source code in src/gc_batch/logger.py
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 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 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 | |
console_output = console_output
instance-attribute
file_output = file_output
instance-attribute
format_string = format_string
instance-attribute
level = level
instance-attribute
log_file = Path(log_file) if log_file else None
instance-attribute
logger = logging.getLogger(name)
instance-attribute
name = name
instance-attribute
__init__(name='default', level=logging.INFO, log_file=None, console_output=True, file_output=False, format_string=None)
Initialize the logger.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
Logger name |
'default'
|
level
|
int
|
Logging level (DEBUG, INFO, WARNING, ERROR, CRITICAL) |
INFO
|
log_file
|
str | Path | None
|
Path to log file (if file_output is True) |
None
|
console_output
|
bool
|
Whether to output to console |
True
|
file_output
|
bool
|
Whether to output to file |
False
|
format_string
|
str | None
|
Custom format string for log messages |
None
|
Source code in src/gc_batch/logger.py
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 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 | |
critical(message)
Log a critical message.
Source code in src/gc_batch/logger.py
92 93 94 | |
debug(message)
Log a debug message.
Source code in src/gc_batch/logger.py
76 77 78 | |
error(message)
Log an error message.
Source code in src/gc_batch/logger.py
88 89 90 | |
get_level_name()
Get the current logging level name.
Source code in src/gc_batch/logger.py
107 108 109 | |
info(message)
Log an info message.
Source code in src/gc_batch/logger.py
80 81 82 | |
is_enabled_for(level)
Check if logging is enabled for the given level.
Source code in src/gc_batch/logger.py
111 112 113 | |
log(level, message)
Log a message at the specified level.
Source code in src/gc_batch/logger.py
96 97 98 | |
set_level(level)
Set the logging level.
Source code in src/gc_batch/logger.py
100 101 102 103 104 105 | |
warning(message)
Log a warning message.
Source code in src/gc_batch/logger.py
84 85 86 | |
get_logger(name='default', level=logging.INFO, log_file=None, console_output=True, file_output=False)
Get a logger instance with the specified configuration.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
Logger name |
'default'
|
level
|
int
|
Logging level |
INFO
|
log_file
|
str | Path | None
|
Path to log file |
None
|
console_output
|
bool
|
Whether to output to console |
True
|
file_output
|
bool
|
Whether to output to file |
False
|
Returns:
| Type | Description |
|---|---|
Logger
|
Logger instance |
Source code in src/gc_batch/logger.py
117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 | |