Utility Modules
Logger is a minimal, extensible logging utility with real-time broadcasting support.
It supports: - INFO, WARN, ERROR, DEBUG log levels - Custom listeners per instance or globally - Timestamped log dispatching without printing directly to stdout - Debug filtering controlled by the constructor flag
Listeners can be used to pipe logs to GUIs, files, or consoles with color formatting.
Source code in utils/logger.py
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 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 |
|
__init__(name='ORS', enable_debug=False)
Initialize a Logger instance.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
name
|
str
|
Logical name for the logger (e.g., module or plugin name). |
'ORS'
|
enable_debug
|
bool
|
Whether DEBUG messages should be emitted. |
False
|
Source code in utils/logger.py
42 43 44 45 46 47 48 49 50 51 52 |
|
add_global_listener(listener_func)
classmethod
Registers a listener that receives logs from all Logger instances, current and future.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
listener_func
|
function
|
Callable with signature (level, name, message, timestamp). |
required |
Source code in utils/logger.py
54 55 56 57 58 59 60 61 62 |
|
add_listener(listener_func)
Adds a listener for this specific logger instance.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
listener_func
|
function
|
Callable with signature (level, name, message, timestamp). |
required |
Source code in utils/logger.py
64 65 66 67 68 69 70 71 |
|
debug(message)
Log a DEBUG-level message (only if enabled).
Source code in utils/logger.py
133 134 135 |
|
error(message)
Log an ERROR-level message.
Source code in utils/logger.py
129 130 131 |
|
info(message)
Log an INFO-level message.
Source code in utils/logger.py
121 122 123 |
|
remove_listener(listener_func)
Removes a previously added listener from this logger instance.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
listener_func
|
function
|
The listener function to remove. |
required |
Source code in utils/logger.py
73 74 75 76 77 78 79 80 81 |
|
warn(message)
Log a WARN-level message.
Source code in utils/logger.py
125 126 127 |
|