Skip to content

Handler Management

Stream, file, and global logger coordination.


HandlerManager

Python
HandlerManager(logger_instance: Logger, formatter_factory)

Manages logging handlers - adding, removing, configuring.

add_file_handler

Python
add_file_handler(filename: str, config: LoggerConfigState, max_bytes: int = 10485760, backup_count: int = 5, level: logLevels = None, formatter: Optional[Formatter] = None, base_level: str = 'INFO') -> Optional[logging.Handler]

Add a rotating file handler.

close_all_handlers

Python
close_all_handlers()

Close all handlers and clean up resources.

flush_all_handlers

Python
flush_all_handlers()

Flush all handlers associated with the logger instance.

get_handler_info

Python
get_handler_info() -> Dict[str, Dict]

Get information about all attached handlers.

update_all_formatters

Python
update_all_formatters(config_state, env_metadata: Dict, global_stream_configured: bool = False)

Update formatters for all handlers based on new config.

update_handler_levels

Python
update_handler_levels(level: LogLevel, *, scope: Literal['owned', 'others', 'all'] = 'owned') -> None

Update handler levels on the WrenchCL logger instance.

scope='owned' -> only handlers tagged _wrench_owned (primary/managed) scope='others' -> only non-owned, user-attached handlers scope='all' -> both

GlobalLoggerManager

Python
GlobalLoggerManager(formatter_factory, handler_manager, internal_logger)

Root-level logging governance: 1) Ensure root logger emits via WrenchCL formatters 2) Enable selective silencing for package loggers 3) Optionally install exception hooks and suppress std streams

refresh_root_formatter

Python
refresh_root_formatter(config_state, env_metadata) -> None

Re-bind the formatter for the root/global handler(s) to keep output shape (JSON/terminal fields) in sync with WrenchCL without touching levels or streams. No-ops if no global stream is configured.

set_root_level

Python
set_root_level(level: logLevels) -> None

Explicitly set the root logger effective level (does not touch instance).