koi_net.infra.log_system
Logging system for all components, lifecycle, and assembly processes.
Classes
|
Configures and initializes the logging system. |
|
Writes logs to partitioned file supporting multiple nodes running simultaneously in the same execution environment. |
- class koi_net.infra.log_system.LogSystem(use_file_handler=True, use_console_handler=True, file_handler_log_level=10, console_handler_log_level=10)[source]
Bases:
objectConfigures and initializes the logging system.
Uses two log handlers by default. One prints to the console, the other produces NDJSON log files, which can be viewed using LNAV.
- Parameters:
use_file_handler (bool)
use_console_handler (bool)
file_handler_log_level (int)
console_handler_log_level (int)
- console_handler_log_level: int
- static delete_file_handler(log_dir, wipe_logs=False)[source]
- Parameters:
log_dir (str)
wipe_logs (bool)
- file_handler_log_level: int
- use_console_handler: bool
- use_file_handler: bool
- class koi_net.infra.log_system.PartitionedFileHandler(log_file_name='log.ndjson', max_log_file_size=10485760, num_log_file_backups=5, log_file_encoding='utf-8')[source]
Bases:
HandlerWrites logs to partitioned file supporting multiple nodes running simultaneously in the same execution environment.
Intended to be used with
LoggingContextcomponent, which binds a node’sroot_dirto thelog_dircontext var. As a result, every node in an execution environment should send logs to the log file in their own root directory. Oftentimes logs produced by third party libraries fall through the cracks and are written todropped_logs.txtinstead as a fallback.This system is overly complicated and is worth refactoring.
- Parameters:
log_file_name (str)
max_log_file_size (int)
num_log_file_backups (int)
log_file_encoding (str)
- emit(record)[source]
Do whatever it takes to actually log the specified logging record.
This version is intended to be implemented by subclasses and so raises a NotImplementedError.
- Parameters:
record (LogRecord)
- handlers: dict[str, RotatingFileHandler]