# prakhar-luke-dev/my_logger architecture

> Architecture diagram of the GitHub repository prakhar-luke-dev/my_logger, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-04-01). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/prakhar-luke-dev/my_logger
- Repository: https://github.com/prakhar-luke-dev/my_logger

## Overview

##### Main Components
- Client Code: The consumer or client code that imports the library and calls the setup functions to obtain logger instances.
- Logger Setup Module (llogger.py): This is the main entry point for configuring loggers. It handles setting up file logging, JSON logging, and network logging (Logstash).
- JSON Formatter Module (jsonformatter.py): When JSON formatting is requested, this component formats the log messages following the provided scheme.
- Logstash Integration: Although implemented within the logger setup, this represents the pathway where logs are sent over the network to a Logstash endpoint.
- Future Extensions (Bugsnag Integration): Although not fully implemented, this is indicated for future enhancements, so consider it as a potential component that may wrap or extend logger functionality.
- Configuration & Packaging: The presence of configuration files (pyproject.toml, setup.cfg) indicates that the project prepares for packaging and distribution.

##### Depicting the Relationships and Interactions
- Within the Logger Setup module, include a decision branch:
- One branch connects to a “File Logging Handler” component when logging to files.
- Another branch, when JSON formatting is enabled, shows a connection from “Logger Setup” to the “JSON Formatter Module (jsonformatter.py)” before directing logs to a file or over the network.
- Additionally, include a branch to “Logstash Integration” when the client specifies logstash_host and logstash_port.

##### Architecture Patterns & Design Principles
- Separation of Concerns: The design clearly separates the logger configuration (llogger.py) from the message formatting (jsonformatter.py), which is critical for maintainability.
- Extensibility: The structure explicitly supports extensions (e.g., future Bugsnag integration) without major refactoring.
- Encapsulation: Client code interacts only with the public API (setup_logger and add_bugsnag_to_logger), abstracting the internal logging management.

##### Relevant Technologies and Frameworks
- Python, as the core language.
- Standard logging libraries (implicitly used or extended within this project).
- Integration with external systems like Logstash.
- Optional integration with a third-party error monitoring tool like Bugsnag.

- From “Logger Setup”, branch out:
- Optionally, add a branch from “Logger Setup” (or label next to it) for the “Logstash Integration.”
- Small annotations that indicate configuration elements like “log_handler”, “use_json”, “log_file”, and “logstash_host/port.”

## Diagram (Mermaid)

```mermaid
graph TD
    %% Client Layer
    Client["Client Code"]:::core

    %% Logger Module Subgraph
    subgraph "Logger Module"
        llogger["Logger Setup Module (llogger.py)"]:::core
        fileHandler["File Logging Handler"]:::core
        jsonformatter["JSON Formatter Module (jsonformatter.py)"]:::core
        logstash["Logstash Integration"]:::core
        bugsnag["Future: Bugsnag Integration"]:::external
    end

    %% Configuration & Packaging Subgraph
    subgraph "Configuration & Packaging"
        pyproject["pyproject.toml"]:::config
        setupcfg["setup.cfg"]:::config
    end

    %% Connections
    Client -->|"calls_setup_logger"| llogger
    llogger -->|"file_logging"| fileHandler
    llogger -->|"json_format_enabled"| jsonformatter
    jsonformatter -->|"formats_for"| fileHandler
    llogger -->|"if_logstash"| logstash
    logstash -->|"sends_logs"| fileHandler
    llogger -.->|"integrate_Bugsnag"| bugsnag

    %% Click Events
    click llogger "https://github.com/prakhar-luke-dev/my_logger/blob/main/logs_operations/llogger.py"
    click jsonformatter "https://github.com/prakhar-luke-dev/my_logger/blob/main/logs_operations/jsonformatter.py"
    click logstash "https://github.com/prakhar-luke-dev/my_logger/blob/main/logs_operations/llogger.py"
    click pyproject "https://github.com/prakhar-luke-dev/my_logger/blob/main/pyproject.toml"
    click setupcfg "https://github.com/prakhar-luke-dev/my_logger/blob/main/setup.cfg"

    %% Styles
    classDef core fill:#AED6F1,stroke:#1B4F72,stroke-width:2px;
    classDef external fill:#FAD7A0,stroke:#D68910,stroke-width:2px;
    classDef config fill:#D5F5E3,stroke:#27AE60,stroke-width:2px;
```
