logging
plantimager.commons.logging Link
Logging System for Application Monitoring
A comprehensive logging system that provides structured, configurable logging capabilities for tracking application events, errors, and performance metrics across different components.
create_logger Link
create_logger(name, level=DEBUG)
Create a logger with the given name and specified logging level.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
name
|
str
|
Name of the logger. This identifies the logger in the hierarchy. |
required |
level
|
int
|
Logging level of the logger. Must be one of DEBUG, INFO, WARNING, ERROR, CRITICAL from the logging module. Default is logging.DEBUG. |
DEBUG
|
Returns:
Type | Description |
---|---|
Logger
|
Configured logger object with stream handler and level-specific formatting. |
Notes
- The logger uses colorlog.LevelFormatter for colored output in console
- Different log levels have different format patterns:
- DEBUG: Includes timestamp, name, thread, level, message, filename, and line number
- INFO: Simplified format with timestamp, name, thread, level, and message
- WARNING/ERROR/CRITICAL: Similar to DEBUG format with file location information
Examples:
>>> from plantimager.commons.logging import create_logger
>>> logger = create_logger("my_app")
>>> logger.info("Application started")
[timestamp] my_app MainThread - INFO: Application started
>>> logger.error("An error occurred")
[timestamp] my_app MainThread - ERROR: An error occurred (logging.py:123)
Source code in plantimager/commons/logging.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 |
|