zooui.logger module¶
Centralized logging configuration for ZooUI.
- class zooui.logger.LoggerConfig[source]¶
Bases:
object- Constructor :
LoggerConfig()
- Parameters :
None
LoggerConfig() –> None
Centralized logger configuration for ZooUI.
Provides consistent logging across all modules with support for: - Multiple log levels (DEBUG, INFO, WARNING, ERROR, CRITICAL) - Console and file output - Rotating log files - Color-coded console output (optional) - Per-module log level control
- _initialized = True¶
- _log_dir = PosixPath('/home/asd/.local/state/zooui/logs')¶
- _log_file = PosixPath('/home/asd/.local/state/zooui/logs/zooui.log')¶
- _console_level = 30¶
- _file_level = 20¶
- _loggers = {'LoggerConfig': <Logger zooui.LoggerConfig (DEBUG)>, 'SVGArrowUtils': <Logger zooui.SVGArrowUtils (DEBUG)>, 'SVGCircleUtils': <Logger zooui.SVGCircleUtils (DEBUG)>, 'SVGSquareUtils': <Logger zooui.SVGSquareUtils (DEBUG)>, 'SVGStickUtils': <Logger zooui.SVGStickUtils (DEBUG)>, 'SVGTriangleUtils': <Logger zooui.SVGTriangleUtils (DEBUG)>}¶
- COLORS = {'CRITICAL': '\x1b[35m', 'DEBUG': '\x1b[36m', 'ERROR': '\x1b[31m', 'INFO': '\x1b[32m', 'RESET': '\x1b[0m', 'WARNING': '\x1b[33m'}¶
- classmethod initialize(debug=False, log_to_file=True, log_to_console=True, log_dir=None, colored_output=True, verbose=False)[source]¶
- Method :
LoggerConfig.initialize(debug, log_to_file, log_to_console, log_dir, colored_output, verbose)
- Parameters :
debug : bool log_to_file : bool log_to_console : bool log_dir : str colored_output : bool verbose : bool
LoggerConfig.initialize(debug, log_to_file, log_to_console, log_dir, colored_output, verbose) –> None
Initialize the logging system.
- Parameters:
debug (bool) – Enable debug mode (sets console level to DEBUG)
log_to_file (bool) – Enable logging to file
log_to_console (bool) – Enable logging to console
log_dir (str) – Directory for log files (default: ./logs)
colored_output (bool) – Enable colored console output
verbose (bool) – Enable verbose mode (shows more detailed info)
- classmethod get_logger(name)[source]¶
- Method :
LoggerConfig.get_logger(name)
- Parameters :
name : str
LoggerConfig.get_logger(name) –> logging.Logger
Get a logger instance for the specified module.
- Parameters:
name (str) – Name of the module/class requesting the logger
- Returns:
Configured logger instance
- Return type:
logging.Logger
- classmethod set_level(level, module=None)[source]¶
- Method :
LoggerConfig.set_level(level, module)
- Parameters :
level : int module : str
LoggerConfig.set_level(level, module) –> None
Change the logging level at runtime.
- Parameters:
level (int) – Logging level (e.g., logging.DEBUG, logging.INFO)
module (str) – Specific module name, or None for all modules
- classmethod enable_debug()[source]¶
- Method :
LoggerConfig.enable_debug()
- Parameters :
None
LoggerConfig.enable_debug() –> None
Enable debug mode at runtime.
- class zooui.logger.ColoredFormatter(fmt=None, datefmt=None, style='%', validate=True, *, defaults=None)[source]¶
Bases:
Formatter- Constructor :
ColoredFormatter()
- Parameters :
None
ColoredFormatter() –> None
Custom formatter that adds color to console output.
Initialize the formatter with specified format strings.
Initialize the formatter either with the specified format string, or a default as described above. Allow for specialized date formatting with the optional datefmt argument. If datefmt is omitted, you get an ISO8601-like (or RFC 3339-like) format.
Use a style parameter of ‘%’, ‘{’ or ‘$’ to specify that you want to use one of %-formatting,
str.format()({}) formatting orstring.Templateformatting in your format string.Changed in version 3.2: Added the
styleparameter.
- zooui.logger.get_logger(name)[source]¶
- Function :
get_logger(name)
- Parameters :
name : str
get_logger(name) –> logging.Logger
Convenience function to get a logger.
- Parameters:
name (str) – Name of the module/class requesting the logger
- Returns:
Configured logger instance
- Return type:
logging.Logger
See Also¶
zooui/config - Logging configuration
Program Configuration - Configuration options