A Fast and Convenient C++ Logging Library for Low-latency or Real-time Environments

Overview

xtr

Ubuntu-GCC Ubuntu-GCC-Conan Ubuntu-GCC-Sanitizer Ubuntu-GCC-CMake

Ubuntu-Clang Ubuntu-Clang-Sanitizer

FreeBSD-13-GCC FreeBSD-14-GCC

FreeBSD-13-Clang FreeBSD-14-Clang

codecov Documentation CodeQL

What is it?

XTR is a C++ logging library aimed at applications with low-latency or real-time requirements. The cost of log statements is minimised by delegating as much work as possible to a background thread.

It is designed so that the cost of a log statement is consistently fast---i.e. every call is fast, not just the average case. No allocations or system calls are made when a log statement is made.

Features

  • Fast (please see benchmark results).
  • No allocations when logging, even when logging strings.
  • Formatting, I/O etc are all delegated to a background thread. Work done at the log statement call-site is minimized---for example a no argument log statement only involves writing a single pointer to a ring buffer.
  • Safe: No references taken to arguments unless explicitly requested.
  • Comprehensive suite of unit tests which run cleanly under AddressSanitizer, UndefinedBehaviourSanitizer, ThreadSanitizer and LeakSanitizer.
  • Log sinks with independent log levels (so that levels for different subsystems may be modified independently).
  • Ability to modify log levels via an external command.
  • Non-printable characters are sanitized for safety (to prevent terminal escape sequence injection attacks).
  • Formatting done via fmtlib.
  • Support for custom I/O back-ends (e.g. to log to the network or syslogd).
  • Support for logrotate integration.
  • Support for systemd journal integration.

Supported platforms

  • Linux (x86-64)
  • FreeBSD (x86-64)

Documentation

https://choll.github.io/xtr

Benchmarks

Below is the output of make benchmark on a stock Ryzen 5950X, with g++ version 10.2.1. No cores are isolated. Benchmarks with isolation, and on other CPUs will be completed soon.

2021-07-31 22:30:11
Running build/g++-release/benchmark/benchmark
Run on (32 X 6614.06 MHz CPU s)
CPU Caches:
  L1 Data 32K (x16)
  L1 Instruction 32K (x16)
  L2 Unified 512K (x16)
  L3 Unified 32768K (x2)
Load Average: 1.26, 1.53, 1.42
***WARNING*** CPU scaling is enabled, the benchmark real time measurements may be noisy and will incur extra overhead.
-----------------------------------------------------------------------------------------
Benchmark                                               Time             CPU   Iterations
-----------------------------------------------------------------------------------------
logger_benchmark_discard                             3.12 ns         3.11 ns    220642542
logger_benchmark_devnull                             3.17 ns         3.16 ns    213233572
logger_benchmark_tsc_discard                         9.97 ns         9.95 ns     71544694
logger_benchmark_tsc_devnull                         9.81 ns         9.79 ns     72024706
logger_benchmark_clock_realtime_coarse_discard       9.50 ns         9.48 ns     75301078
logger_benchmark_clock_realtime_coarse_devnull       9.02 ns         8.99 ns     77431937
logger_benchmark_int_discard                         4.64 ns         4.63 ns    151861070
logger_benchmark_int_devnull                         4.62 ns         4.61 ns    151949835
logger_benchmark_long_discard                        4.61 ns         4.60 ns    151969132
logger_benchmark_long_devnull                        4.61 ns         4.60 ns    152198709
logger_benchmark_double_discard                      4.84 ns         4.82 ns    145809754
logger_benchmark_double_devnull                      4.81 ns         4.80 ns    145367066
logger_benchmark_c_str_discard                       7.63 ns         7.60 ns     93103583
logger_benchmark_c_str_devnull                       7.33 ns         7.30 ns     95755773
logger_benchmark_str_view_discard                    5.69 ns         5.66 ns    122769764
logger_benchmark_str_view_devnull                    5.67 ns         5.64 ns    124657115
logger_benchmark_str_discard                         7.36 ns         7.33 ns     96002018
logger_benchmark_str_devnull                         7.32 ns         7.29 ns     96072575
logger_benchmark_non_blocking_discard                3.13 ns         3.12 ns    224529741
logger_benchmark_non_blocking_devnull                3.09 ns         3.08 ns    228207878

Installation notes

See INSTALL.md

You might also like...
A lightweight C++ logging library
A lightweight C++ logging library

Loguru: a lightweight and flexible C++ logging library. At a glance Documentation Documentation can be found at https://emilk.github.io/loguru/index.h

Cute Log is a C++ Library that competes to be a unique logging tool.

Cute Log Cute Log is a C++ Library that competes to be a unique logging tool. Version: 2 Installation Click "Code" on the main repo page (This one.).

Boost Logging library

Boost.Log, part of collection of the Boost C++ Libraries, provides tools for adding logging to libraries and applications. Directories build - Boost.L

log4cplus is a simple to use C++ logging API providing thread-safe, flexible, and arbitrarily granular control over log management and configuration. It is modelled after the Java log4j API.

% log4cplus README Short Description log4cplus is a simple to use C++17 logging API providing thread--safe, flexible, and arbitrarily granular control

Netdata's distributed, real-time monitoring Agent collects thousands of metrics from systems, hardware, containers, and applications with zero configuration.
Netdata's distributed, real-time monitoring Agent collects thousands of metrics from systems, hardware, containers, and applications with zero configuration.

Netdata is high-fidelity infrastructure monitoring and troubleshooting. It runs permanently on all your physical/virtual servers, containers, cloud deployments, and edge/IoT devices, and is perfectly safe to install on your systems mid-incident without any preparation.

C++ implementation of the Google logging module

Google Logging Library The Google Logging Library (glog) implements application-level logging. The library provides logging APIs based on C++-style st

Uberlog - Cross platform multi-process C++ logging system

uberlog uberlog is a cross platform C++ logging system that is: Small Fast Robust Runs on Linux, Windows, OSX MIT License Small Two headers, and three

An Ultra Low Power temperature logger based on the ESP8266 MCU.
An Ultra Low Power temperature logger based on the ESP8266 MCU.

Temperature logging IoT node Overview: The real node wired on a breadboard This is an ultra low power (ULP) temperature logging IoT node based on the

Comments
  • Add CMake support

    Add CMake support

    This PR adds cmake support to this project, including building tests and benchmark.

    I also added a minimal documentation how to use it in INSTALL.md file

    Regards!

    close #2

    opened by uilianries 2
Releases(2.0.1)
Owner
null
Asynchronous Low Latency C++ Logging Library

Quill Asynchronous Low Latency C++ Logging Library Introduction Features Performance Supported Platforms And Compilers Basic Usage CMake Integration D

Odysseas Georgoudis 668 Nov 22, 2022
fmtlog is a performant fmtlib-style logging library with latency in nanoseconds.

fmtlog fmtlog is a performant asynchronous logging library using fmt library format. Features Faster - lower runtime latency than NanoLog and higher t

Meng Rao 425 Nov 20, 2022
Colorful Logging is a simple and efficient library allowing for logging and benchmarking.

Colorful-Logging "Colorful Logging" is a library allowing for simple and efficient logging as well for benchmarking. What can you use it for? -Obvious

Mateusz Antkiewicz 1 Feb 17, 2022
logog is a portable C++ library to facilitate logging of real-time events in performance-oriented applications

logog is a portable C++ library to facilitate logging of real-time events in performance-oriented applications, such as games. It is especially appropriate for projects that have constrained memory and constrained CPU requirements.

John Byrd 46 Oct 21, 2020
Fast C++ logging library.

spdlog Very fast, header-only/compiled, C++ logging library. Install Header only version Copy the source folder to your build tree and use a C++11 com

Gabi Melman 16.2k Nov 20, 2022
Portable, simple and extensible C++ logging library

Plog - portable, simple and extensible C++ logging library Pretty powerful logging library in about 1000 lines of code Introduction Hello log! Feature

Sergey Podobry 1.6k Nov 26, 2022
Minimalistic logging library with threads and manual callstacks

Minimalistic logging library with threads and manual callstacks

Sergey Kosarevsky 21 Jun 24, 2022
Yet another logging library.

Blackhole - eating your logs with pleasure Blackhole is an attribute-based logger with strong focus on gaining maximum performance as possible for suc

Evgeny Safronov 190 Oct 13, 2022