# platformlab/nanolog architecture

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

- Interactive diagram: https://gitdiagram.com/platformlab/nanolog
- Repository: https://github.com/platformlab/nanolog

## Overview

NanoLog is a C++ logging system that records dynamic arguments in a compact binary log and defers human-readable formatting to decompression. Its two usage paths are the C++17 API and the compile-time preprocessor; both serve application logging, followed by runtime capture and offline decoding. The README documents this overall pipeline, while source excerpts are partial, so internal wiring not established by the evidence is omitted.

Main entry points: [`runtime/RuntimeLogger.cc`](https://github.com/platformlab/nanolog/blob/master/runtime/RuntimeLogger.cc) (Runtime Logger), [`runtime/LogDecompressor.cc`](https://github.com/platformlab/nanolog/blob/master/runtime/LogDecompressor.cc) (Decompressor), [`runtime/GeneratedCode.h`](https://github.com/platformlab/nanolog/blob/master/runtime/GeneratedCode.h) (Generated Code), [`runtime/NanoLogCpp17.h`](https://github.com/platformlab/nanolog/blob/master/runtime/NanoLogCpp17.h) (C++17 API)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_api["Logging APIs"]
  node_cpp17["C++17 API<br/>[NanoLogCpp17.h]"]
  node_parser["Log Parser<br/>[parser.py]"]
  node_generator["Code Generator"]
  node_generated["Generated Code<br/>[GeneratedCode.h]"]
end

subgraph group_capture["Runtime Capture"]
  node_logger["Runtime Logger<br/>[RuntimeLogger.cc]"]
  node_logcodec["Log Codec<br/>[Log.cc]"]
  node_logfile[("Binary Log")]
end

subgraph group_decode["Offline Decoding"]
  node_decompressor["Decompressor<br/>[LogDecompressor.cc]"]
  node_textlog["Readable Log"]
end

subgraph group_support["Runtime Support"]
  node_config["Log Configuration<br/>[Config.h]"]
  node_cycles["Cycle Timing<br/>[Cycles.cc]"]
end

node_app(("C++ Application"))

node_app -->|"logs through"| node_cpp17
node_app -.->|"preprocesses source"| node_parser
node_parser -.->|"generates code"| node_generator
node_generator -.->|"emits logging code"| node_generated
node_app -.->|"logs through"| node_generated
node_cpp17 -->|"records messages"| node_logger
node_generated -.->|"records messages"| node_logger
node_logger -->|"encodes entries"| node_logcodec
node_logger -->|"writes binary log"| node_logfile
node_logfile -->|"reads binary log"| node_decompressor
node_decompressor -->|"decodes entries"| node_logcodec
node_decompressor -->|"formats output"| node_textlog
node_logger -->|"reads settings"| node_config
node_logger -->|"timestamps entries"| node_cycles

click node_cpp17 "https://github.com/platformlab/nanolog/blob/master/runtime/NanoLogCpp17.h"
click node_parser "https://github.com/platformlab/nanolog/blob/master/preprocessor/parser.py"
click node_generator "https://github.com/platformlab/nanolog/blob/master/preprocessor/FunctionGenerator.py"
click node_generated "https://github.com/platformlab/nanolog/blob/master/runtime/GeneratedCode.h"
click node_logger "https://github.com/platformlab/nanolog/blob/master/runtime/RuntimeLogger.cc"
click node_logcodec "https://github.com/platformlab/nanolog/blob/master/runtime/Log.cc"
click node_decompressor "https://github.com/platformlab/nanolog/blob/master/runtime/LogDecompressor.cc"
click node_config "https://github.com/platformlab/nanolog/blob/master/runtime/Config.h"
click node_cycles "https://github.com/platformlab/nanolog/blob/master/runtime/Cycles.cc"

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_cpp17,node_parser,node_generator,node_generated toneBlue
class node_logger,node_logcodec,node_logfile toneAmber
class node_decompressor,node_textlog toneMint
class node_config,node_cycles toneRose
class node_app toneIndigo
```

## Components

### Logging APIs

- [C++17 API](https://github.com/platformlab/nanolog/blob/master/runtime/NanoLogCpp17.h): `runtime/NanoLogCpp17.h`
- [Log Parser](https://github.com/platformlab/nanolog/blob/master/preprocessor/parser.py): `preprocessor/parser.py`
- [Code Generator](https://github.com/platformlab/nanolog/blob/master/preprocessor/FunctionGenerator.py): `preprocessor/FunctionGenerator.py`
- [Generated Code](https://github.com/platformlab/nanolog/blob/master/runtime/GeneratedCode.h): `runtime/GeneratedCode.h`

### Runtime Capture

- [Runtime Logger](https://github.com/platformlab/nanolog/blob/master/runtime/RuntimeLogger.cc): `runtime/RuntimeLogger.cc`
- [Log Codec](https://github.com/platformlab/nanolog/blob/master/runtime/Log.cc): `runtime/Log.cc`
- **Binary Log**

### Offline Decoding

- [Decompressor](https://github.com/platformlab/nanolog/blob/master/runtime/LogDecompressor.cc): `runtime/LogDecompressor.cc`
- **Readable Log**

### Runtime Support

- [Log Configuration](https://github.com/platformlab/nanolog/blob/master/runtime/Config.h): `runtime/Config.h`
- [Cycle Timing](https://github.com/platformlab/nanolog/blob/master/runtime/Cycles.cc): `runtime/Cycles.cc`

### Other components

- **C++ Application**

## Connections

- C++ Application → C++17 API: logs through
- C++ Application → Log Parser: preprocesses source
- Log Parser → Code Generator: generates code
- Code Generator → Generated Code: emits logging code
- C++ Application → Generated Code: logs through
- C++17 API → Runtime Logger: records messages
- Generated Code → Runtime Logger: records messages
- Runtime Logger → Log Codec: encodes entries
- Runtime Logger → Binary Log: writes binary log
- Binary Log → Decompressor: reads binary log
- Decompressor → Log Codec: decodes entries
- Decompressor → Readable Log: formats output
- Runtime Logger → Log Configuration: reads settings
- Runtime Logger → Cycle Timing: timestamps entries
