# ThreadSafeCLogger

> A high-performance thread-safe logging library for C. Per-thread SPSC ring buffers drained by a background logger thread — zero mutex contention on the write path. 15× throughput improvement over naive mutex approach.

URL: https://harshith.in/projects/thread-safe-c-logger/
Author: Harshith Sunku (Staff Engineer) — https://harshith.in/about/
Source: https://github.com/harshithsunku/ThreadSafeCLogger
Stack: C, Lock-Free, POSIX Threads, Ring Buffer, Memory Ordering

A logging library designed so the hot path never blocks. Each producer thread
owns a single-producer/single-consumer ring buffer; a dedicated background thread
drains them and serializes writes. The result is zero mutex contention on the
write path and roughly a 15× throughput improvement over a naive mutex approach.
