# ankitgupt-a/loggingframeworklld architecture

> Architecture diagram of the GitHub repository ankitgupt-a/loggingframeworklld, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-08-15). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/ankitgupt-a/loggingframeworklld
- Repository: https://github.com/ankitgupt-a/loggingframeworklld

## Overview

##### Project type and purpose
- This is an open-source, low-level design of a logging framework (library) in Java.
- It provides a central API (Logger, LogManager) for client code to emit log messages, routes messages through a handler chain, and distributes them to various “sinks” (console, file, database, etc.).

##### File structure
- src/LoggerApplication.java — example client or entry-point showing how to use the framework.
- src/Logger, LogLevel — core logging API (interface or abstract class + enum).
- src/LogManager — likely a centralized factory or singleton that hands back configured Logger instances.
- src/LoggerHandler — implements the Chain-of-Responsibility pattern to route log calls by level.
- src/LogSinkSubject, LogObserver — implement the Observer pattern to register/unregister sinks.
- src/ConsoleLogger, FileLogger, DataBaseLogger, InfoLogger, DebugLogger, ErrorLogger — concrete observers or handlers that do the actual writing.

##### README for additional insights
- The README points to a Medium article describing low-level design of a logging framework.

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% API Layer
    subgraph "API Layer"
        direction TB
        Client["LoggerApplication"]:::core
        InterfaceLogger["Logger (Interface)"]:::core
        EnumLogLevel["LogLevel (Enum)"]:::core
    end

    %% Core Engine
    subgraph "Core Engine"
        direction TB
        Factory["LogManager (Singleton/Factory)"]:::core
        HandlerChain["LoggerHandler (CoR)"]:::core
        InfoHandler["InfoLogger"]:::core
        DebugHandler["DebugLogger"]:::core
        ErrorHandler["ErrorLogger"]:::core
    end

    %% Event Distribution
    subgraph "Event Distribution"
        direction TB
        Subject["LogSinkSubject (Observer Subject)"]:::core
        ObserverIntf["LogObserver (Interface)"]:::core
    end

    %% Concrete Sinks
    subgraph "Concrete Sinks"
        direction TB
        ConsoleObs["ConsoleLogger"]:::extension
        FileObs["FileLogger"]:::extension
        DBObs["DataBaseLogger"]:::extension
    end

    %% External Systems
    subgraph "External Systems"
        direction TB
        ExternalConsole["Console (STDOUT)"]:::external
        ExternalFile["File System"]:::external
        ExternalDB["Database"]:::external
    end

    %% Connections
    Client -->|"calls getLogger()"| Factory
    Factory -->|"returns Logger"| InterfaceLogger
    InterfaceLogger -->|"log(level, msg)"| HandlerChain
    HandlerChain -->|"route by level"| InfoHandler
    InfoHandler -->|"forward"| DebugHandler
    DebugHandler -->|"forward"| ErrorHandler
    ErrorHandler -->|"notify observers"| Subject
    Subject -->|"implements LogObserver"| ObserverIntf
    ObserverIntf -->|"registered observers"| ConsoleObs
    ObserverIntf -->|"registered observers"| FileObs
    ObserverIntf -->|"registered observers"| DBObs
    ConsoleObs -->|"writes to"| ExternalConsole
    FileObs -->|"writes to"| ExternalFile
    DBObs -->|"writes to"| ExternalDB

    %% Click Events
    click Client "https://github.com/ankitgupt-a/loggingframeworklld/blob/main/src/LoggerApplication.java"
    click Factory "https://github.com/ankitgupt-a/loggingframeworklld/blob/main/src/LogManager.java"
    click InterfaceLogger "https://github.com/ankitgupt-a/loggingframeworklld/blob/main/src/Logger.java"
    click EnumLogLevel "https://github.com/ankitgupt-a/loggingframeworklld/blob/main/src/LogLevel.java"
    click HandlerChain "https://github.com/ankitgupt-a/loggingframeworklld/blob/main/src/LoggerHandler.java"
    click Subject "https://github.com/ankitgupt-a/loggingframeworklld/blob/main/src/LogSinkSubject.java"
    click ObserverIntf "https://github.com/ankitgupt-a/loggingframeworklld/blob/main/src/LogObserver.java"
    click ConsoleObs "https://github.com/ankitgupt-a/loggingframeworklld/blob/main/src/ConsoleLogger.java"
    click FileObs "https://github.com/ankitgupt-a/loggingframeworklld/blob/main/src/FileLogger.java"
    click DBObs "https://github.com/ankitgupt-a/loggingframeworklld/blob/main/src/DataBaseLogger.java"
    click InfoHandler "https://github.com/ankitgupt-a/loggingframeworklld/blob/main/src/InfoLogger.java"
    click DebugHandler "https://github.com/ankitgupt-a/loggingframeworklld/blob/main/src/DebugLogger.java"
    click ErrorHandler "https://github.com/ankitgupt-a/loggingframeworklld/blob/main/src/ErrorLogger.java"

    %% Styles
    classDef core fill:#BBE1FA,stroke:#1B262C,stroke-width:1px
    classDef extension fill:#B7E4C7,stroke:#1B262C,stroke-width:1px
    classDef external fill:#FFDDD2,stroke:#1B262C,stroke-width:1px
```
