Skip to content

config

Framework Logging Configuration.

Provides utility functions to configure the logging system for the framework. Includes colorful log formatting, the ability to configure logging levels and destinations, and a function to inspect the current logging hierarchy for debugging. Environment variables may be used for initial configuration.

Example
configure_logging(log_level="DEBUG", log_dir="/path/to/logs")
print_loggers()

Attributes

Classes

ColorfulFormatter

Bases: Formatter

Formatter to add coloring to log messages by log type

Attributes

COLORS class-attribute instance-attribute
COLORS = {
    "DEBUG": LIGHTWHITE_EX,
    "WARNING": YELLOW,
    "ERROR": RED,
    "CRITICAL": RED + BRIGHT,
}

Functions

format
format(record)

Functions

configure_logging

configure_logging(
    log_level: str = getenv(ENV_ELEANOR_LOG_LEVEL, "INFO"),
    log_dir: str | None = getenv(ENV_ELEANOR_LOG_DIR, None),
)

Configures logging for the framework.

Parameters:

  • log_level (str, default: getenv(ENV_ELEANOR_LOG_LEVEL, 'INFO') ) –

    The log level to set. Defaults to “INFO”. log_dir

  • (str (| None) –

    The directory to store log files. Defaults to None.

Environment Variables

ENV_ELEANOR_LOG_LEVEL (str): The log level to set. Overrides the log_level argument if provided. ENV_ELEANOR_LOG_DIR (str): The directory to store log files. Overrides the log_dir argument if provided.

get_logger_hierarchy

get_logger_hierarchy() -> str

This function iterates through all the loggers in the logging module’s logger dictionary and collects information about each logger, including its name, level, propagation status, disabled status, and parent logger. The collected information is then returned as a formatted string.

Returns:

  • str ( str ) –

    A formatted string containing the hierarchy of all loggers.