# hyeongryong/jdlogger architecture

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

- Interactive diagram: https://gitdiagram.com/hyeongryong/jdlogger
- Repository: https://github.com/hyeongryong/jdlogger

## Overview

##### Main Components

a. Core Layer:
- ILogFormatter interface
- ILogModel interface
- ILoggerScope interface
- Core models (LogEntity, ExceptionInfo)

b. Formatting Layer:
- JDLoggerFormatter (main formatter)
- Different formatter implementations (CSV, JSON, TabDelimited)
- LogDataPreparer
- Attributes system (ExportIgnore)

c. Persistence Layer:
- A "Persistence" component containing:
- Logger extensions
- Mapper implementations
- Scope implementations (JDLoggerAdapter, JDLoggerScope)

d. SQLite Storage:
- Database component as the underlying storage system

##### Relationships and Data Flow

- Client Application → JDLogger (entry point)
- JDLogger → LoggerScope (scope creation)
- LoggerScope → Formatters (data formatting)
- LoggerScope → Persistence Layer (data storage)
- Persistence Layer → SQLite Storage (final storage)

##### Detailed Elements

a. Entry Points:
- Initialize() method
- BeginScope<T>() method

b. Core Operations:
- Logging flow
- Query capabilities
- Export operations
- Exception handling

c. Extension Points:
- Custom formatters
- Custom log models
- Log handlers

##### Implementation Notes

- Different log levels
- Scope inheritance
- Data flow directions
- Threading model
- Extension points

##### Architecture Patterns

Following patterns:
- Repository pattern for data access
- Strategy pattern for formatting
- Observer pattern for log handlers
- Chain of responsibility for scope hierarchy

##### Storage Layer

Remember to include notes about:
- Thread-safety mechanisms
- Scope hierarchy handling
- Custom model support
- Export functionality
- Exception handling flow

This structure will provide a clear visualization of how JDLogger works as a lightweight, yet feature-rich logging solution while maintaining its architectural integrity and extensibility points.

## Diagram (Mermaid)

```mermaid
graph TB
    subgraph Client
        CA[Client Application]:::client
    end

    subgraph Core["Core Layer"]
        direction TB
        ILF["ILogFormatter"]:::interface
        ILM["ILogModel"]:::interface
        ILS["ILoggerScope"]:::interface
        LE["LogEntity"]:::model
        EI["ExceptionInfo"]:::model
        click ILF "https://github.com/HyeongRyong/JDLogger/blob/master/JDLogger/Core/Abstractions/ILogFormatter.cs"
        click ILM "https://github.com/HyeongRyong/JDLogger/blob/master/JDLogger/Core/Abstractions/ILogModel.cs"
        click ILS "https://github.com/HyeongRyong/JDLogger/blob/master/JDLogger/Core/Abstractions/ILoggerScope.cs"
        click LE "https://github.com/HyeongRyong/JDLogger/blob/master/JDLogger/Core/Models/LogEntity.cs"
        click EI "https://github.com/HyeongRyong/JDLogger/blob/master/JDLogger/Core/Models/ExceptionInfo.cs"
    end

    subgraph Formatting["Formatting Layer"]
        direction TB
        JLF["JDLoggerFormatter"]:::formatter
        CSVF["CSV Formatter"]:::formatter
        JSONF["JSON Formatter"]:::formatter
        TABF["Tab Delimited Formatter"]:::formatter
        LDP["LogDataPreparer"]:::formatter
        EA["Export Attributes"]:::formatter
        click JLF "https://github.com/HyeongRyong/JDLogger/blob/master/JDLogger/Formatting/JDLoggerFormatter.cs"
        click CSVF "https://github.com/HyeongRyong/JDLogger/blob/master/JDLogger/Formatting/Formatters/CsvLogFormatter.cs"
        click JSONF "https://github.com/HyeongRyong/JDLogger/blob/master/JDLogger/Formatting/Formatters/JsonLogFormatter.cs"
        click TABF "https://github.com/HyeongRyong/JDLogger/blob/master/JDLogger/Formatting/Formatters/TabDelimitedFormatter.cs"
        click LDP "https://github.com/HyeongRyong/JDLogger/blob/master/JDLogger/Formatting/LogDataPreparer.cs"
        click EA "https://github.com/HyeongRyong/JDLogger/blob/master/JDLogger/Formatting/Attributes/ExportIgnoreAttribute.cs"
    end

    subgraph Persistence["Persistence Layer"]
        direction TB
        LE_["Logger Extensions"]:::persistence
        SE["Scope Extensions"]:::persistence
        LMM["Log Model Mapper"]:::persistence
        LEM["Log Entity Mapper"]:::persistence
        JLS["JDLogger Scope"]:::persistence
        JLA["JDLogger Adapter"]:::persistence
        click LE_ "https://github.com/HyeongRyong/JDLogger/blob/master/JDLogger/Persistence/Extensions/LoggerExtensions.cs"
        click SE "https://github.com/HyeongRyong/JDLogger/blob/master/JDLogger/Persistence/Extensions/LoggerScopeExtensions.cs"
        click LMM "https://github.com/HyeongRyong/JDLogger/blob/master/JDLogger/Persistence/Mapper/LogModelMapper.cs"
        click LEM "https://github.com/HyeongRyong/JDLogger/blob/master/JDLogger/Persistence/Mapper/LogEntityMapper.cs"
        click JLS "https://github.com/HyeongRyong/JDLogger/blob/master/JDLogger/Persistence/Scopes/JDLoggerScope.cs"
        click JLA "https://github.com/HyeongRyong/JDLogger/blob/master/JDLogger/Persistence/Scopes/JDLoggerAdapter.cs"
    end

    subgraph Storage["Storage Layer"]
        DB[(SQLite Database)]:::storage
    end

    JDL["JDLogger Main"]:::main
    click JDL "https://github.com/HyeongRyong/JDLogger/blob/master/JDLogger/JDLogger.cs"

    %% Relationships
    CA --> JDL
    JDL --> ILS
    JDL --> JLS
    JLS --> JLF
    JLF --> CSVF & JSONF & TABF
    JLS --> LDP
    LDP --> EA
    JLS --> LE_ & SE
    LE_ --> LMM
    SE --> LEM
    LMM & LEM --> DB

    %% Styles
    classDef client fill:#9370DB,stroke:#333,stroke-width:2px
    classDef interface fill:#FFD700,stroke:#333,stroke-width:2px
    classDef model fill:#4169E1,stroke:#333,stroke-width:2px
    classDef formatter fill:#98FB98,stroke:#333,stroke-width:2px
    classDef persistence fill:#FFA500,stroke:#333,stroke-width:2px
    classDef storage fill:#808080,stroke:#333,stroke-width:2px
    classDef main fill:#FF6B6B,stroke:#333,stroke-width:2px

    %% Legend
    subgraph Legend
        L1[Client]:::client
        L2[Interface]:::interface
        L3[Model]:::model
        L4[Formatter]:::formatter
        L5[Persistence]:::persistence
        L6[(Storage)]:::storage
        L7[Main Entry]:::main
    end
```
