Skip to content

Latest commit

 

History

History
85 lines (55 loc) · 7.52 KB

File metadata and controls

85 lines (55 loc) · 7.52 KB
graph LR
    Logger_Core["Logger Core"]
    Handler_Dispatcher["Handler & Dispatcher"]
    Sink_Implementations["Sink Implementations"]
    Exception_Formatting_Utilities["Exception & Formatting Utilities"]
    Log_Record_Configuration_Utilities["Log Record & Configuration Utilities"]
    Logger_Core -- "Dispatches log messages to" --> Handler_Dispatcher
    Logger_Core -- "Utilizes" --> Log_Record_Configuration_Utilities
    Handler_Dispatcher -- "Receives log records from" --> Logger_Core
    Handler_Dispatcher -- "Dispatches processed messages to" --> Sink_Implementations
    Handler_Dispatcher -- "Utilizes" --> Exception_Formatting_Utilities
    Sink_Implementations -- "Receives processed log messages from" --> Handler_Dispatcher
    Sink_Implementations -- "Relies on" --> Log_Record_Configuration_Utilities
    Exception_Formatting_Utilities -- "Used by" --> Handler_Dispatcher
    Exception_Formatting_Utilities -- "Receives raw exception data from" --> Log_Record_Configuration_Utilities
    Log_Record_Configuration_Utilities -- "Provides log record data to" --> Logger_Core
    Log_Record_Configuration_Utilities -- "Provides log record data to" --> Handler_Dispatcher
    Log_Record_Configuration_Utilities -- "Supports" --> Sink_Implementations
    click Logger_Core href "https://github.com/CodeBoarding/GeneratedOnBoardings/blob/main//loguru/Logger_Core.md" "Details"
    click Handler_Dispatcher href "https://github.com/CodeBoarding/GeneratedOnBoardings/blob/main//loguru/Handler_Dispatcher.md" "Details"
    click Sink_Implementations href "https://github.com/CodeBoarding/GeneratedOnBoardings/blob/main//loguru/Sink_Implementations.md" "Details"
    click Exception_Formatting_Utilities href "https://github.com/CodeBoarding/GeneratedOnBoardings/blob/main//loguru/Exception_Formatting_Utilities.md" "Details"
    click Log_Record_Configuration_Utilities href "https://github.com/CodeBoarding/GeneratedOnBoardings/blob/main//loguru/Log_Record_Configuration_Utilities.md" "Details"
Loading

CodeBoardingDemoContact

Component Details

The architecture of loguru is designed around a clear separation of concerns, enabling robust and flexible logging. Based on the Control Flow Graph (CFG) and Source Analysis, the system can be distilled into five fundamental components: Logger Core, Handler & Dispatcher, Sink Implementations, Exception & Formatting Utilities, and Log Record & Configuration Utilities. These components represent the core responsibilities and interaction points within the loguru library, handling everything from message creation and processing to output and advanced formatting, forming a cohesive and efficient logging architecture.

Logger Core

This is the primary user-facing API and the central orchestrator of the Loguru logging system. It provides the public interface for users to emit log messages (e.g., logger.info(), logger.debug()), configure global logging behavior (adding/removing sinks, setting levels), and initiates the log processing pipeline for every message. It's the entry point for all logging operations.

Related Classes/Methods:

Handler & Dispatcher

This component acts as an intermediary, receiving raw log records from the Logger Core. Its primary responsibilities include applying filtering based on severity level and custom rules, formatting the log message according to the handler's specific configuration, managing an optional multiprocessing-safe queue for non-blocking I/O operations, and then dispatching the final processed message to its designated Sink Implementations.

Related Classes/Methods:

Sink Implementations

This component represents a collection of concrete destinations for log output. It includes specialized File Sink implementations that provide robust file management features (automatic file rotation by size or time, retention policies, compression of archived log files), as well as Stream & Callable Sinks for writing to standard I/O streams, executing arbitrary Python callable functions for custom handling, or adapting Loguru records to be compatible with Python's built-in logging module handlers.

Related Classes/Methods:

Exception & Formatting Utilities

This component is dedicated to enhancing the visual presentation and debuggability of log messages. It processes and renders Python exception tracebacks in a more user-friendly and informative manner, including extracting detailed frame information, highlighting relevant code lines, and displaying variable values. Additionally, it manages the application and parsing of ANSI escape codes for colored terminal output, ensuring messages are visually distinct and readable.

Related Classes/Methods:

Log Record & Configuration Utilities

This component provides the foundational data structures and helper functions that support the core logging process and configuration. It is responsible for dynamically constructing the comprehensive dictionary (record) that accompanies each log message (gathering contextual data like time, file info, process/thread IDs, and exception details). It also offers various utility functions for parsing human-readable strings for durations, sizes, and frequencies (used in file rotation/retention), formatting datetime objects, and implementing diverse filtering strategies for log messages.

Related Classes/Methods: