KDAB’s newest open-source library is now publicly available: KDSPDSetup!
KDSPDSetup is a small library written in modern C++ (≥ 20) that initializes objects from the spdlog library by reading a toml configuration file. This makes setting up loggers more convenient and results in cleaner-looking code.
Let's take a look at an example to see how useful it can be. We’ll read the config from a file logConfig.toml
and do some stuff with the loggers KDSPDSetup creates for us.
The config file looks like this:
It’s pretty easy to read and edit this, as there’s not much syntactic noise. Plus, we get to detach all these details from our code, where we focus on functionality and use the loggers where needed.
Without KDSPDSetup, we might have something like this:
There’s a lot of code to accidentally write slightly wrong, and it takes a bit longer to look at references and remember to include all the right headers. KDSPDSetup will do all this for you, so you can spend your time and energy on your program’s functionality.
KDSPDSetup’s development was motivated by KDGpu dropping the dependency spdlog_setup, which served the same purpose, but had not been updated in four years. Although KDGpu developers removed the dependency, it was useful, so they wanted a replacement.
KDSPDSetup was designed to work with the same existing config files that were previously used with spdlog_setup, so it could be used as a drop-in replacement.
These files allow one to fully configure:
- Sinks of several types, formatting patterns, and thread pools (for async loggers), with names so they can be referenced by name when configuring loggers.
- A global pattern and global thread pool that loggers will use when these are not specified in the logger’s configuration.
- Loggers (async or not) with names to register with spdlog, along with the sinks, patterns, and, for async loggers, thread pools to use.
The unstable branch is now officially available on GitHub, and can be used under the terms of the MIT License. Consider giving it a try if you use spdlog and think this would be helpful!
Trusted software excellence across embedded and desktop platforms
The KDAB Group is a globally recognized provider for software consulting, development and training, specializing in embedded devices and complex cross-platform desktop applications. In addition to being leading experts in Qt, C++ and 3D technologies for over two decades, KDAB provides deep expertise across the stack, including Linux, Rust and modern UI frameworks. With 100+ employees from 20 countries and offices in Sweden, Germany, USA, France and UK, we serve clients around the world.