Several weeks ago a friend and I were discussing C++ logging frameworks. He had some issues with his company’s home-made logger, mainly regarding call latencies, and wanted to switch to something better. After some googling around we’ve found a couple of interesting candidates: g3log, NanoLog, MAL and spdlog. All four options aim to be “fast” and use similar approaches to achieve that. In the following posts I’d like to talk about what logging frameworks do, how do they define and measure what “fast” is and showcase a different approach to C++ logging which I’ve been messing around with.

TL;DR

If the requirement of outputting a textual log from the C++ application is relaxed, we can create a faster logging framework. Enter llcpp (literal logging for c++). This framework uses C++17 template (and constexpr) meta-programming magic to reduce the number of allocations needed to zero and eliminates the need to format the data to human readable form. Later, a simple script can be used to transform the log into human readable form. Oh, and we get type safety for free.

Intrigued? skeptical? excited? angry? Read on! (Prefer reading code? Go ahead!)

Post Index

  • Part 1: Why are we logging and what modern logging frameworks in C++ do
  • Part 2: llcpp - A different approach
  • Part 3: Benchmarks - discussion and comparison
  • Part 4: Afterword