Heaton is a high-performance, non-intrusive logging management switch built for modern C++. It features a four-layer decoupled architecture: Upstream (Collection) → Dispatch (Routing) → Sink (Buffering) → Target (Persistence). It unifies log streams from GLog, Abseil, and Turbo, while providing industrial-grade automated operations capabilities.
-
Unified Upstream Using upstream interception technology, Heaton transparently takes over log output from GLog, Abseil, and Turbo, normalizing fragmented logs into a unified time-series stream.
-
Extreme Performance (Zero-copy Dispatch) Achieves zero-copy forwarding on the synchronous path. On the asynchronous path, it uses swap buffers and state-machine signal suppression to minimize syscall overhead.
-
Industrial-Grade Self-Healing Target Built-in Daily/Hourly/Rotating rotation policies, with support for automatic directory creation, disk-full backoff and retry, and automatic cleanup of historical logs.
-
Non-Intrusive Integration No changes to existing business code using
LOG(INFO)are required. A single initialization line inmain()enables global log governance.
flowchart LR
A[APP] --> B[GLOG transfer]
A[APP] --> C[ABSL transfer]
A[APP] --> D[TURBO transfer]
B --> E[dispatcher]
C --> E[dispatcher]
D --> E[dispatcher]
E -->|INFO| GS[sink/async]
E -->|WARN| GS
E -->|ERROR| GS
E -->|FATAL| GS
E -->|ERROR| ES[error]
E -->|FATAL| ES[error]
GS -->|console| CT[target]
GS -->|file| FT[target]
GS -->|kafka| KT[target]
| Feature | Implementation Details |
|---|---|
| Async Pump | Based on std::deque + pointer swapping; lock contention remains constant at nanosecond scale. |
| Signal Suppression | State machine identifies kWorking state and automatically suppresses invalid condition_variable notifications. |
| Memory Control | Strictly follows rvalue reference move semantics to ensure zero secondary copies during asynchronous dispatch. |
| Ops Closed-Loop | Scans existing disk files on restart and reconstructs a circular_queue to manage lifecycle. |
| Error Governance | Uses turbo::Status return codes throughout; no exceptions, with strong binary compatibility. |
This project uses kmpkg for dependency management and build integration. kmpkg automates third-party library downloading, dependency resolution, and compiler flag configuration, eliminating the need for manual maintenance of complex CMake setups.
- Linux (Ubuntu 20.04+ / CentOS 7+ recommended)
- CMake ≥ 3.25
- GCC ≥ 9.4 / Clang ≥ 12
kmpkginstalled (See installation docs)
- Full dependencies are listed in
kmpkg.json - To update the dependency baseline, edit
kmpkg-configuration.jsonand modify thebaselinefield underdefault-registry - The
baselinecan be set to the latest commit viagit log - Optional: Users may manage dependencies manually, as long as CMake
find_packagelocates them correctly- Example: Install dependencies to system or custom paths, then specify via
CMAKE_PREFIX_PATH - Or declare external dependency paths in kmpkg to avoid redundant downloads
- Example: Install dependencies to system or custom paths, then specify via
From the project root:
cmake --preset=default
cmake --build build -j$(nproc)Self-managed dependencies:
mkdir build
cd build
cmake ..
make -j$(nproc)Note
--preset=default requires a corresponding CMake Preset defined in the project root.
From the project root:
ctest --test-dir build#include <heaton/heaton.h>
#include <heaton/glog.h>
#include <turbo/log/logging.h>
int main(int argc, char **argv) {
heaton::HeatonOption option(argv[0]);
option.upstream.enable_absl = true;
option.upstream.enable_turbo = true;
option.upstream.enable_glog = true;
option.create_if_missing = true;
option.global.type = heaton::SinkType::SINK_ASYNC_FILE;
option.global.target.target_type = heaton::TargetType::TARGET_DAILY;
option.global.target.filename = "logs/tlog.txt";
auto rs = heaton::Heaton::get_instance()->initialize(option);
std::cerr << rs.to_string() << std::endl;
if (!rs.ok()) {
return 1;
}
ABSL_LOG(INFO) << "absl log";
KLOG(INFO) << "turbo log";
LOG(INFO) << "glog log";
return 0;
}