Logger
zenml.logger
Logger implementation.
Attributes
ENABLE_RICH_TRACEBACK = handle_bool_env_var(ENV_ZENML_ENABLE_RICH_TRACEBACK, True)
module-attribute
ENV_ZENML_CAPTURE_PRINTS = 'ZENML_CAPTURE_PRINTS'
module-attribute
ENV_ZENML_LOGGING_COLORS_DISABLED = 'ZENML_LOGGING_COLORS_DISABLED'
module-attribute
ENV_ZENML_LOGGING_FORMAT = 'ZENML_LOGGING_FORMAT'
module-attribute
ENV_ZENML_SUPPRESS_LOGS = 'ZENML_SUPPRESS_LOGS'
module-attribute
ZENML_LOGGING_COLORS_DISABLED = handle_bool_env_var(ENV_ZENML_LOGGING_COLORS_DISABLED, False)
module-attribute
ZENML_LOGGING_VERBOSITY = os.getenv(ENV_ZENML_LOGGING_VERBOSITY, default='DEBUG').upper()
module-attribute
ZENML_STORAGE_LOGGING_VERBOSITY = os.getenv(ENV_ZENML_STORAGE_LOGGING_VERBOSITY, default='DEBUG').upper()
module-attribute
logging_handlers: ContextVarList[ArtifactStoreHandler] = ContextVarList('logging_handlers')
module-attribute
step_names_in_console: ContextVar[bool] = ContextVar('step_names_in_console', default=False)
module-attribute
Classes
ArtifactStoreHandler(storage: PipelineLogsStorage)
Bases: Handler
Handler that writes log messages to artifact store storage.
Initialize the handler with a storage instance.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
storage
|
PipelineLogsStorage
|
The PipelineLogsStorage instance to write to. |
required |
Source code in src/zenml/logging/step_logging.py
128 129 130 131 132 133 134 135 136 137 138 |
|
Functions
emit(record: logging.LogRecord) -> None
Emit a log record to the storage.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
record
|
LogRecord
|
The log record to emit. |
required |
Source code in src/zenml/logging/step_logging.py
140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 |
|
ContextVarList(name: str)
Bases: Generic[T]
Thread-safe wrapper around ContextVar[List] with atomic add/remove operations.
Initialize the context variable list.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
name
|
str
|
The name for the underlying ContextVar. |
required |
Source code in src/zenml/utils/context_utils.py
26 27 28 29 30 31 32 33 34 35 36 37 |
|
Functions
add(item: T) -> None
Thread-safely add an item to the list.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
item
|
T
|
The item to add to the list. |
required |
Source code in src/zenml/utils/context_utils.py
48 49 50 51 52 53 54 55 56 57 58 |
|
get() -> List[T]
Get the current list value. Returns empty list if not set.
Returns:
Type | Description |
---|---|
List[T]
|
The current list value. |
Source code in src/zenml/utils/context_utils.py
39 40 41 42 43 44 45 46 |
|
remove(item: T) -> None
Thread-safely remove an item from the list.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
item
|
T
|
The item to remove from the list. |
required |
Source code in src/zenml/utils/context_utils.py
60 61 62 63 64 65 66 67 68 69 70 |
|
CustomFormatter
Bases: Formatter
Formats logs according to custom specifications.
Functions
format(record: logging.LogRecord) -> str
Converts a log record to a (colored) string.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
record
|
LogRecord
|
LogRecord generated by the code. |
required |
Returns:
Type | Description |
---|---|
str
|
A string formatted according to specifications. |
Source code in src/zenml/logger.py
123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 |
|
LoggingLevels
Bases: Enum
Enum for logging levels.
Functions
_add_step_name_to_message(message: str) -> str
Adds the step name to the message.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
message
|
str
|
The message to add the step name to. |
required |
Returns:
Type | Description |
---|---|
str
|
The message with the step name added. |
Source code in src/zenml/logger.py
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 |
|
get_console_handler() -> Any
Get console handler for logging.
Returns:
Type | Description |
---|---|
Any
|
A console handler. |
Source code in src/zenml/logger.py
314 315 316 317 318 319 320 321 322 323 324 |
|
get_formatter() -> logging.Formatter
Get a configured logging formatter.
Returns:
Type | Description |
---|---|
Formatter
|
The formatter. |
Source code in src/zenml/logger.py
302 303 304 305 306 307 308 309 310 311 |
|
get_logger(logger_name: str) -> logging.Logger
Main function to get logger name,.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
logger_name
|
str
|
Name of logger to initialize. |
required |
Returns:
Type | Description |
---|---|
Logger
|
A logger object. |
Source code in src/zenml/logger.py
327 328 329 330 331 332 333 334 335 336 |
|
get_logging_level() -> LoggingLevels
Get logging level from the env variable.
Returns:
Type | Description |
---|---|
LoggingLevels
|
The logging level. |
Raises:
Type | Description |
---|---|
KeyError
|
If the logging level is not found. |
Source code in src/zenml/logger.py
192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 |
|
get_storage_log_level() -> LoggingLevels
Get storage logging level from the env variable with safe fallback.
Returns:
Type | Description |
---|---|
LoggingLevels
|
The storage logging level, defaulting to INFO if invalid. |
Raises:
Type | Description |
---|---|
KeyError
|
If the storage logging level is not found. |
Source code in src/zenml/logger.py
209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 |
|
handle_bool_env_var(var: str, default: bool = False) -> bool
Converts normal env var to boolean.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
var
|
str
|
The environment variable to convert. |
required |
default
|
bool
|
The default value to return if the env var is not set. |
False
|
Returns:
Type | Description |
---|---|
bool
|
The converted value. |
Source code in src/zenml/constants.py
96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 |
|
init_logging() -> None
Initialize logging with default levels.
Source code in src/zenml/logger.py
339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 |
|
set_root_verbosity() -> None
Set the root verbosity.
Source code in src/zenml/logger.py
226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 |
|
setup_global_print_wrapping() -> None
Set up global print() wrapping with context-aware handlers.
Source code in src/zenml/logger.py
243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 |
|