# kinnerfisch/klylogger architecture

> Architecture diagram of the GitHub repository kinnerfisch/klylogger, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-01). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/kinnerfisch/klylogger
- Repository: https://github.com/kinnerfisch/klylogger

## Overview

KlyLogger is a C/C++ logging library whose main workflow accepts level-tagged messages, formats them, submits output work, and writes colored console and optional log-file output. It exposes both a C++ logger and an opaque-handle C API; the C header also provides C11 typed-argument convenience macros. The sampled implementation shows asynchronous task processing, callbacks, color-code handling, and file lifecycle behavior. Internal details are limited to the excerpts and SOURCE INDEX; unsampled C API and formatting internals are not expanded beyond documented behavior.

Main entry points: [`KlyLogger.cpp`](https://github.com/kinnerfisch/klylogger/blob/main/KlyLogger.cpp) (Output Worker), [`KlyLogger.hpp`](https://github.com/kinnerfisch/klylogger/blob/main/KlyLogger.hpp) (C++ Logger), [`KlyLogger.h`](https://github.com/kinnerfisch/klylogger/blob/main/KlyLogger.h) (C Interface), [`fmt`](https://github.com/kinnerfisch/klylogger/tree/main/fmt) (fmt Formatting)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_api["Public APIs"]
  node_cpp_api["C++ Logger<br/>[KlyLogger.hpp]"]
  node_c_api["C Interface<br/>[KlyLogger.h]"]
  node_c_bridge["C API Bridge<br/>[KlyLogger.cpp]"]
end

subgraph group_formatting["Formatting"]
  node_message_format["Message Formatting<br/>[KlyLogger.hpp]"]
  node_fmt["fmt Formatting"]
  node_c_format["C Typed Formatting<br/>[KlyLogger.cpp]"]
  node_string_conversion["String Conversion<br/>[KlyLogger.cpp]"]
end

subgraph group_runtime["Logging Runtime"]
  node_task_queue["Task Queue<br/>[KlyLogger.cpp]"]
  node_worker["Output Worker<br/>[KlyLogger.cpp]"]
  node_line_processing["Line Processing<br/>[KlyLogger.cpp]"]
  node_callbacks["Log Callbacks<br/>[KlyLogger.cpp]"]
end

subgraph group_output["Output"]
  node_console["Console Output<br/>[KlyLogger.cpp]"]
  node_color_codes["Color Handling<br/>[KlyLogger.cpp]"]
  node_file_logger["File Logging<br/>[KlyLogger.cpp]"]
  node_log_files[("Log Files<br/>[KlyLogger.cpp]")]
end

node_developer(("Application"))

node_developer -->|"logs through"| node_cpp_api
node_developer -->|"logs through"| node_c_api
node_cpp_api -->|"formats messages"| node_message_format
node_message_format -->|"formats with"| node_fmt
node_message_format -->|"converts strings"| node_string_conversion
node_cpp_api -->|"submits tasks"| node_task_queue
node_c_api -->|"implemented by"| node_c_bridge
node_c_api -->|"dispatches typed arguments"| node_c_format
node_c_format -->|"formats with"| node_fmt
node_c_bridge -.->|"submits log work"| node_task_queue
node_task_queue -->|"dispatches tasks"| node_worker
node_worker -->|"processes messages"| node_line_processing
node_worker -->|"runs callbacks"| node_callbacks
node_worker -->|"outputs lines"| node_console
node_line_processing -->|"processes codes"| node_color_codes
node_color_codes -->|"sets terminal colors"| node_console
node_console -->|"writes line breaks"| node_file_logger
node_file_logger -->|"writes and rotates"| node_log_files
node_file_logger -->|"converts wide text"| node_string_conversion

click node_cpp_api "https://github.com/kinnerfisch/klylogger/blob/main/KlyLogger.hpp"
click node_c_api "https://github.com/kinnerfisch/klylogger/blob/main/KlyLogger.h"
click node_c_bridge "https://github.com/kinnerfisch/klylogger/blob/main/KlyLogger.cpp"
click node_message_format "https://github.com/kinnerfisch/klylogger/blob/main/KlyLogger.hpp"
click node_fmt "https://github.com/kinnerfisch/klylogger/tree/main/fmt"
click node_c_format "https://github.com/kinnerfisch/klylogger/blob/main/KlyLogger.cpp"
click node_task_queue "https://github.com/kinnerfisch/klylogger/blob/main/KlyLogger.cpp"
click node_worker "https://github.com/kinnerfisch/klylogger/blob/main/KlyLogger.cpp"
click node_line_processing "https://github.com/kinnerfisch/klylogger/blob/main/KlyLogger.cpp"
click node_callbacks "https://github.com/kinnerfisch/klylogger/blob/main/KlyLogger.cpp"
click node_string_conversion "https://github.com/kinnerfisch/klylogger/blob/main/KlyLogger.cpp"
click node_console "https://github.com/kinnerfisch/klylogger/blob/main/KlyLogger.cpp"
click node_color_codes "https://github.com/kinnerfisch/klylogger/blob/main/KlyLogger.cpp"
click node_file_logger "https://github.com/kinnerfisch/klylogger/blob/main/KlyLogger.cpp"
click node_log_files "https://github.com/kinnerfisch/klylogger/blob/main/KlyLogger.cpp"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_cpp_api,node_c_api,node_c_bridge toneBlue
class node_message_format,node_fmt,node_c_format,node_string_conversion toneAmber
class node_task_queue,node_worker,node_line_processing,node_callbacks toneMint
class node_console,node_color_codes,node_file_logger,node_log_files toneRose
class node_developer toneIndigo
```

## Components

### Public APIs

- [C++ Logger](https://github.com/kinnerfisch/klylogger/blob/main/KlyLogger.hpp): `KlyLogger.hpp`
- [C Interface](https://github.com/kinnerfisch/klylogger/blob/main/KlyLogger.h): `KlyLogger.h`
- [C API Bridge](https://github.com/kinnerfisch/klylogger/blob/main/KlyLogger.cpp): `KlyLogger.cpp`

### Formatting

- [Message Formatting](https://github.com/kinnerfisch/klylogger/blob/main/KlyLogger.hpp): `KlyLogger.hpp`
- [fmt Formatting](https://github.com/kinnerfisch/klylogger/tree/main/fmt): `fmt`
- [C Typed Formatting](https://github.com/kinnerfisch/klylogger/blob/main/KlyLogger.cpp): `KlyLogger.cpp`
- [String Conversion](https://github.com/kinnerfisch/klylogger/blob/main/KlyLogger.cpp): `KlyLogger.cpp`

### Logging Runtime

- [Task Queue](https://github.com/kinnerfisch/klylogger/blob/main/KlyLogger.cpp): `KlyLogger.cpp`
- [Output Worker](https://github.com/kinnerfisch/klylogger/blob/main/KlyLogger.cpp): `KlyLogger.cpp`
- [Line Processing](https://github.com/kinnerfisch/klylogger/blob/main/KlyLogger.cpp): `KlyLogger.cpp`
- [Log Callbacks](https://github.com/kinnerfisch/klylogger/blob/main/KlyLogger.cpp): `KlyLogger.cpp`

### Output

- [Console Output](https://github.com/kinnerfisch/klylogger/blob/main/KlyLogger.cpp): `KlyLogger.cpp`
- [Color Handling](https://github.com/kinnerfisch/klylogger/blob/main/KlyLogger.cpp): `KlyLogger.cpp`
- [File Logging](https://github.com/kinnerfisch/klylogger/blob/main/KlyLogger.cpp): `KlyLogger.cpp`
- [Log Files](https://github.com/kinnerfisch/klylogger/blob/main/KlyLogger.cpp): `KlyLogger.cpp`

### Other components

- **Application**

## Connections

- Application → C++ Logger: logs through (evidence: `README.md`)
- Application → C Interface: logs through (evidence: `README.md`)
- C++ Logger → Message Formatting: formats messages (evidence: `KlyLogger.hpp`)
- Message Formatting → fmt Formatting: formats with (evidence: `KlyLogger.hpp`)
- Message Formatting → String Conversion: converts strings (evidence: `KlyLogger.hpp`)
- C++ Logger → Task Queue: submits tasks (evidence: `KlyLogger.hpp`)
- C Interface → C API Bridge: implemented by (evidence: `KlyLogger.cpp`)
- C Interface → C Typed Formatting: dispatches typed arguments (evidence: `KlyLogger.h`)
- C Typed Formatting → fmt Formatting: formats with (evidence: `README.md`)
- C API Bridge → Task Queue: submits log work (evidence: `KlyLogger.cpp`)
- Task Queue → Output Worker: dispatches tasks (evidence: `KlyLogger.cpp`)
- Output Worker → Line Processing: processes messages (evidence: `KlyLogger.cpp`)
- Output Worker → Log Callbacks: runs callbacks (evidence: `KlyLogger.cpp`)
- Output Worker → Console Output: outputs lines (evidence: `KlyLogger.cpp`)
- Line Processing → Color Handling: processes codes (evidence: `KlyLogger.cpp`)
- Color Handling → Console Output: sets terminal colors (evidence: `KlyLogger.cpp`)
- Console Output → File Logging: writes line breaks (evidence: `KlyLogger.cpp`)
- File Logging → Log Files: writes and rotates (evidence: `KlyLogger.cpp`)
- File Logging → String Conversion: converts wide text (evidence: `KlyLogger.cpp`)
