A high-performance, lock-free logging utility written in modern C++. This project is designed for ultra-low-latency logging in multithreaded environments such as trading systems, real-time analytics, or high-frequency data pipelines.
- β Lock-Free Logging (SPSC ring buffer)
- β Thread-safe background writer
- β Log Levels: INFO, WARN, ERROR
- β Timestamped Messages
- β Pre-allocated message buffer (no dynamic allocation during log)
- β Log Rotation (by date and file size)
- β Performance Benchmarking (average latency per log call)
- π οΈ Easy to extend to multi-producer with Boost or custom lock-free queue
.
βββ src/
β βββ LogLevel.h
β βββ LogEntry.h
β βββ LockFreeRingBuffer.h
β βββ LockFreeLogger.h
β βββ main.cpp
βββ logs/
βββ README.md
π Performance
- The logger records the time taken to enqueue log entries and reports average latency at the end of execution.
- Ideal for applications where logging should not block real-time processing or introduce jitter.
π§± How It Works
- Producer threads push LogEntry objects into a lock-free ring buffer.
- A background thread dequeues and writes logs to disk.
- Supports log rotation:
- Daily (new file each day)
- Max file size (e.g., 10MB)