Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/odygrd/quill
Asynchronous Low Latency C++ Logging Library
https://github.com/odygrd/quill
async asynchronous cpp cpp14 cpp17 cpp20 cross-platform fmtlib high-performance log-library logger logging logging-library low-latency
Last synced: 5 days ago
JSON representation
Asynchronous Low Latency C++ Logging Library
- Host: GitHub
- URL: https://github.com/odygrd/quill
- Owner: odygrd
- License: mit
- Created: 2020-01-15T23:22:33.000Z (almost 5 years ago)
- Default Branch: master
- Last Pushed: 2024-11-27T21:20:44.000Z (15 days ago)
- Last Synced: 2024-12-06T21:13:46.467Z (6 days ago)
- Topics: async, asynchronous, cpp, cpp14, cpp17, cpp20, cross-platform, fmtlib, high-performance, log-library, logger, logging, logging-library, low-latency
- Language: C++
- Homepage:
- Size: 7.2 MB
- Stars: 1,579
- Watchers: 29
- Forks: 163
- Open Issues: 10
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
- awesomecpp - Quill - - cross-platform low latency logging library based on C++14. (Logging)
- awesome-code-for-gamedev - odygrd/quill - Asynchronous Low Latency Logging Library (Footprints , Logging / UI Test Automation Scripting)
README
Quill
Asynchronous Low Latency C++ Logging Library
π Documentation
Β·
β‘ Cheat Sheet
Β·
π Report Bug
Β·
π‘ Request Feature
## π§ Table of Contents
- [Introduction](#-introduction)
- [Quick Start](#-quick-start)
- [Features](#-features)
- [Performance](#-performance)
- [Usage](#-usage)
- [Design](#-design)
- [Caveats](#-caveats)
- [License](#-license)## β¨ Introduction
Quill is a high-performance asynchronous logging library. It is particularly suited for performance-critical
applications where every microsecond counts.- **Performance-Focused**: Quill consistently outperforms many popular logging libraries.
- **Feature-Rich**: Packed with advanced features to meet diverse logging needs.
- **Battle-Tested**: Proven in demanding production environments.
- **Extensive Documentation**: Comprehensive guides and examples available.
- **Community-Driven**: Open to contributions, feedback, and feature requests.Try it on [Compiler Explorer](https://godbolt.org/z/zEsxsxcoq)
## β© Quick Start
Getting started is easy and straightforward. Follow these steps to integrate the library into your project:
### Installation
You can install Quill using the package manager of your choice:
| Package Manager | Installation Command |
|:---------------:|:----------------------------------------------:|
| vcpkg | `vcpkg install quill` |
| Conan | `conan install quill` |
| Homebrew | `brew install quill` |
| Meson WrapDB | `meson wrap install quill` |
| Conda | `conda install -c conda-forge quill` |
| Bzlmod | `bazel_dep(name = "quill", version = "x.y.z")` |
| xmake | `xrepo install quill` |
| nix | `nix-shell -p quill-log` |### Setup
Once installed, you can start using Quill with the following code:
```c++
#include "quill/Backend.h"
#include "quill/Frontend.h"
#include "quill/LogMacros.h"
#include "quill/Logger.h"
#include "quill/sinks/ConsoleSink.h"
#includeint main()
{
quill::Backend::start();quill::Logger* logger = quill::Frontend::create_or_get_logger(
"root", quill::Frontend::create_or_get_sink("sink_id_1"));LOG_INFO(logger, "Hello from {}!", std::string_view{"Quill"});
}
```## π― Features
- **High-Performance**: Ultra-low latency performance. View [Benchmarks](http://github.com/odygrd/quill#performance)
- **Asynchronous Processing**: Background thread handles formatting and I/O, keeping your main thread responsive.
- **Minimal Header Includes**:
- **Frontend**: Only `Logger.h` and `LogMacros.h` needed for logging. Lightweight with minimal dependencies.
- **Backend**: Single `.cpp` file inclusion. No backend code injection into other translation units.
- **Compile-Time Optimization**: Eliminate specific log levels at compile time.
- **Custom Formatters**: Define your own log output patterns.
See [Formatters](https://quillcpp.readthedocs.io/en/latest/formatters.html).
- **Timestamp-Ordered Logs**: Simplify debugging of multithreaded applications with chronologically ordered logs.
- **Flexible Timestamps**: Support for `rdtsc`, `chrono`, or `custom clocks` - ideal for simulations and more.
- **Backtrace Logging**: Store messages in a ring buffer for on-demand display.
See [Backtrace Logging](https://quillcpp.readthedocs.io/en/latest/backtrace_logging.html)
- **Multiple Output Sinks**: Console (with color), files (with rotation), JSON, ability to create custom sinks and more.
- **Log Filtering**: Process only relevant messages.
See [Filters](https://quillcpp.readthedocs.io/en/latest/filters.html).
- **JSON Logging**: Structured log output.
See [JSON Logging](https://quillcpp.readthedocs.io/en/latest/json_logging.html)
- **Configurable Queue Modes**: `bounded/unbounded` and `blocking/dropping` options with monitoring on dropped messages,
queue reallocations, and blocked hot threads.
- **Crash Handling**: Built-in signal handler for log preservation during crashes.
- **Huge Pages Support (Linux)**: Leverage huge pages on the hot path for optimized performance.
- **Wide Character Support (Windows)**: Compatible with ASCII-encoded wide strings and STL containers consisting of wide
strings.
- **Exception-Free Option**: Configurable builds with or without exception handling.
- **Clean Codebase**: Maintained to high standards, warning-free even at strict levels.
- **Type-Safe API**: Built on [{fmt}](http://github.com/fmtlib/fmt) library.## π Performance
### System Configuration
- **OS:** Linux RHEL 9.4
- **CPU:** Intel Core i5-12600 (12th Gen) @ 4.8 GHz
- **Compiler:** GCC 13.1
- **Benchmark-Tuned System:** The system is specifically tuned for benchmarking.- **Command Line Parameters:**
```shell
$ cat /proc/cmdline
BOOT_IMAGE=(hd0,gpt2)/vmlinuz-5.14.0-427.13.1.el9_4.x86_64 root=/dev/mapper/rhel-root ro crashkernel=1G-4G:192M,4G-64G:256M,64G-:512M resume=/dev/mapper/rhel-swap rd.lvm.lv=rhel/root rd.lvm.lv=rhel/swap rhgb quiet nohz=on nohz_full=1-5 rcu_nocbs=1-5 isolcpus=1-5 mitigations=off transparent_hugepage=never intel_pstate=disable nosoftlockup irqaffinity=0 processor.max_cstate=1 nosoftirqd sched_tick_offload=0 spec_store_bypass_disable=off spectre_v2=off iommu=pt
```You can find the benchmark code on the [logger_benchmarks](http://github.com/odygrd/logger_benchmarks) repository.
### Latency
The results presented in the tables below are measured in `nanoseconds (ns)`.
The tables are sorted by the 95th percentile
#### Logging Numbers
`LOG_INFO(logger, "Logging int: {}, int: {}, double: {}", i, j, d)`.
##### 1 Thread Logging
| Library | 50th | 75th | 90th | 95th | 99th | 99.9th |
|----------------------------------------------------------------|:----:|:----:|:----:|:----:|:----:|:------:|
| [Quill Bounded Dropping Queue](http://github.com/odygrd/quill) | 7 | 8 | 8 | 9 | 9 | 11 |
| [fmtlog](http://github.com/MengRao/fmtlog) | 9 | 9 | 10 | 10 | 12 | 13 |
| [Quill Unbounded Queue](http://github.com/odygrd/quill) | 10 | 10 | 10 | 10 | 12 | 14 |
| [PlatformLab NanoLog](http://github.com/PlatformLab/NanoLog) | 13 | 14 | 16 | 17 | 19 | 25 |
| [MS BinLog](http://github.com/Morgan-Stanley/binlog) | 21 | 21 | 22 | 22 | 56 | 93 |
| [XTR](https://github.com/choll/xtr) | 7 | 7 | 29 | 30 | 33 | 53 |
| [Reckless](http://github.com/mattiasflodin/reckless) | 26 | 28 | 31 | 32 | 35 | 49 |
| [BqLog](https://github.com/Tencent/BqLog) | 29 | 29 | 30 | 49 | 56 | 71 |
| [Iyengar NanoLog](http://github.com/Iyengar111/NanoLog) | 83 | 96 | 117 | 125 | 152 | 197 |
| [spdlog](http://github.com/gabime/spdlog) | 143 | 147 | 152 | 158 | 165 | 177 |
| [g3log](http://github.com/KjellKod/g3log) | 1161 | 1259 | 1329 | 1419 | 1602 | 1827 |![numbers_1_thread_logging.webp](docs%2Fcharts%2Fnumbers_1_thread_logging.webp)
##### 4 Threads Logging Simultaneously
| Library | 50th | 75th | 90th | 95th | 99th | 99.9th |
|----------------------------------------------------------------|:----:|:----:|:----:|:----:|:----:|:------:|
| [fmtlog](http://github.com/MengRao/fmtlog) | 8 | 9 | 9 | 10 | 11 | 13 |
| [Quill Bounded Dropping Queue](http://github.com/odygrd/quill) | 8 | 9 | 10 | 10 | 12 | 14 |
| [XTR](https://github.com/choll/xtr) | 7 | 8 | 9 | 11 | 31 | 38 |
| [Quill Unbounded Queue](http://github.com/odygrd/quill) | 10 | 11 | 11 | 12 | 13 | 15 |
| [PlatformLab NanoLog](http://github.com/PlatformLab/NanoLog) | 15 | 17 | 20 | 23 | 27 | 32 |
| [MS BinLog](http://github.com/Morgan-Stanley/binlog) | 21 | 22 | 22 | 23 | 62 | 100 |
| [Reckless](http://github.com/mattiasflodin/reckless) | 19 | 23 | 26 | 28 | 34 | 55 |
| [BqLog](https://github.com/Tencent/BqLog) | 31 | 33 | 34 | 55 | 61 | 73 |
| [Iyengar NanoLog](http://github.com/Iyengar111/NanoLog) | 58 | 90 | 123 | 131 | 168 | 242 |
| [spdlog](http://github.com/gabime/spdlog) | 210 | 243 | 288 | 313 | 382 | 694 |
| [g3log](http://github.com/KjellKod/g3log) | 1271 | 1337 | 1396 | 1437 | 1614 | 1899 |![numbers_4_thread_logging.webp](docs%2Fcharts%2Fnumbers_4_thread_logging.webp)
#### Logging Large Strings
Logging `std::string` over 35 characters to prevent the short string optimization.
`LOG_INFO(logger, "Logging int: {}, int: {}, string: {}", i, j, large_string)`.
##### 1 Thread Logging
| Library | 50th | 75th | 90th | 95th | 99th | 99.9th |
|----------------------------------------------------------------|:----:|:----:|:----:|:----:|:----:|:------:|
| [Quill Bounded Dropping Queue](http://github.com/odygrd/quill) | 11 | 13 | 13 | 14 | 15 | 16 |
| [fmtlog](http://github.com/MengRao/fmtlog) | 11 | 12 | 13 | 14 | 15 | 17 |
| [Quill Unbounded Queue](http://github.com/odygrd/quill) | 14 | 15 | 16 | 17 | 18 | 19 |
| [MS BinLog](http://github.com/Morgan-Stanley/binlog) | 22 | 23 | 24 | 25 | 61 | 100 |
| [PlatformLab NanoLog](http://github.com/PlatformLab/NanoLog) | 15 | 17 | 21 | 27 | 33 | 39 |
| [XTR](https://github.com/choll/xtr) | 8 | 9 | 29 | 31 | 35 | 54 |
| [BqLog](https://github.com/Tencent/BqLog) | 29 | 30 | 31 | 51 | 60 | 71 |
| [Reckless](http://github.com/mattiasflodin/reckless) | 91 | 107 | 115 | 118 | 124 | 135 |
| [Iyengar NanoLog](http://github.com/Iyengar111/NanoLog) | 86 | 97 | 119 | 128 | 159 | 268 |
| [spdlog](http://github.com/gabime/spdlog) | 120 | 124 | 128 | 132 | 141 | 151 |
| [g3log](http://github.com/KjellKod/g3log) | 881 | 956 | 1018 | 1089 | 1264 | 1494 |![large_strings_1_thread_logging.webp](docs%2Fcharts%2Flarge_strings_1_thread_logging.webp)
##### 4 Threads Logging Simultaneously
| Library | 50th | 75th | 90th | 95th | 99th | 99.9th |
|----------------------------------------------------------------|:----:|:----:|:----:|:----:|:----:|:------:|
| [XTR](https://github.com/choll/xtr) | 9 | 11 | 13 | 14 | 32 | 40 |
| [fmtlog](http://github.com/MengRao/fmtlog) | 11 | 12 | 13 | 14 | 16 | 19 |
| [Quill Bounded Dropping Queue](http://github.com/odygrd/quill) | 13 | 14 | 15 | 16 | 17 | 19 |
| [Quill Unbounded Queue](http://github.com/odygrd/quill) | 15 | 16 | 17 | 18 | 19 | 21 |
| [MS BinLog](http://github.com/Morgan-Stanley/binlog) | 23 | 25 | 27 | 28 | 65 | 105 |
| [PlatformLab NanoLog](http://github.com/PlatformLab/NanoLog) | 16 | 20 | 32 | 38 | 44 | 51 |
| [BqLog](https://github.com/Tencent/BqLog) | 32 | 33 | 35 | 56 | 64 | 76 |
| [Reckless](http://github.com/mattiasflodin/reckless) | 79 | 94 | 104 | 107 | 114 | 132 |
| [Iyengar NanoLog](http://github.com/Iyengar111/NanoLog) | 85 | 93 | 125 | 133 | 168 | 237 |
| [spdlog](http://github.com/gabime/spdlog) | 178 | 218 | 261 | 281 | 381 | 651 |
| [g3log](http://github.com/KjellKod/g3log) | 992 | 1055 | 1121 | 1178 | 1360 | 1600 |![large_strings_4_thread_logging.webp](docs%2Fcharts%2Flarge_strings_4_thread_logging.webp)
#### Logging Complex Types
Logging `std::vector` containing 16 large strings, each ranging from 50 to 60 characters.
Note: some of the previous loggers do not support passing a `std::vector` as an argument.
`LOG_INFO(logger, "Logging int: {}, int: {}, vector: {}", i, j, v)`.
##### 1 Thread Logging
| Library | 50th | 75th | 90th | 95th | 99th | 99.9th |
|----------------------------------------------------------------|:----:|:----:|:----:|:----:|:----:|:------:|
| [Quill Bounded Dropping Queue](http://github.com/odygrd/quill) | 48 | 50 | 53 | 55 | 58 | 62 |
| [Quill Unbounded Queue](http://github.com/odygrd/quill) | 54 | 56 | 57 | 58 | 61 | 66 |
| [MS BinLog](http://github.com/Morgan-Stanley/binlog) | 68 | 69 | 72 | 74 | 79 | 281 |
| [XTR](https://github.com/choll/xtr) | 284 | 294 | 340 | 346 | 356 | 575 |
| [fmtlog](http://github.com/MengRao/fmtlog) | 711 | 730 | 754 | 770 | 804 | 834 |
| [spdlog](http://github.com/gabime/spdlog) | 6191 | 6261 | 6330 | 6386 | 6633 | 7320 |![vector_1_thread_logging.webp](docs%2Fcharts%2Fvector_1_thread_logging.webp)
##### 4 Threads Logging Simultaneously
| Library | 50th | 75th | 90th | 95th | 99th | 99.9th |
|----------------------------------------------------------------|:----:|:----:|:----:|:----:|:----:|:------:|
| [Quill Bounded Dropping Queue](http://github.com/odygrd/quill) | 50 | 52 | 54 | 56 | 60 | 82 |
| [MS BinLog](http://github.com/Morgan-Stanley/binlog) | 70 | 72 | 75 | 79 | 88 | 286 |
| [Quill Unbounded Queue](http://github.com/odygrd/quill) | 97 | 107 | 116 | 122 | 135 | 148 |
| [XTR](https://github.com/choll/xtr) | 512 | 711 | 761 | 791 | 865 | 945 |
| [fmtlog](http://github.com/MengRao/fmtlog) | 780 | 804 | 823 | 835 | 860 | 896 |
| [spdlog](http://github.com/gabime/spdlog) | 6469 | 6549 | 6641 | 6735 | 7631 | 9430 |![vector_4_thread_logging.webp](docs%2Fcharts%2Fvector_4_thread_logging.webp)
The benchmark methodology involves logging 20 messages in a loop, calculating and storing the average latency for those
20 messages, then waiting around ~2 milliseconds, and repeating this process for a specified number of iterations._In the `Quill Bounded Dropping` benchmarks, the dropping queue size is set to `262,144` bytes, which is double the
default size of `131,072` bytes._### Throughput
Throughput is measured by calculating the maximum number of log messages the backend logging thread can write to a log
file per second.The tests were run on the same system used for the latency benchmarks.
Although Quillβs primary focus is not on maximizing throughput, it efficiently manages log messages across multiple
threads. Benchmarking throughput of asynchronous logging libraries presents certain challenges. Some libraries may drop
log messages, leading to smaller-than-expected log files, while others only provide asynchronous flushing, making it
difficult to verify when the backend thread has fully processed all messages.For comparison, we benchmark against other asynchronous logging libraries that offer guaranteed logging with a
flush-and-wait mechanism.Note that `MS BinLog` writes log data to a binary file, which requires offline formatting with an additional
programβthis makes it an unfair comparison, but it is included for reference.Similarly, `BqLog (binary log)` uses the compressed binary log appender, and its log files are not human-readable unless
processed offline. However, it is included for reference. The other version of `BqLog` is using a text appender and
produces human-readable log files.In the same way, `Platformlab Nanolog` also outputs binary logs and is expected to deliver high throughput. However, for
reasons unexplained, the benchmark runs significantly slower (10x longer) than the other libraries, so it is excluded
from the table.Logging 4 million times the message `"Iteration: {} int: {} double: {}"`
| Library | million msg/second | elapsed time |
|-------------------------------------------------------------------|:------------------:|:------------:|
| [MS BinLog (binary log)](http://github.com/Morgan-Stanley/binlog) | 63.80 | 62 ms |
| [BqLog (binary log)](https://github.com/Tencent/BqLog) | 15.92 | 251 ms |
| [Quill](http://github.com/odygrd/quill) | 5.70 | 701 ms |
| [BqLog](https://github.com/Tencent/BqLog) | 4.93 | 811 ms |
| [spdlog](http://github.com/gabime/spdlog) | 3.54 | 1128 ms |
| [fmtlog](http://github.com/MengRao/fmtlog) | 2.90 | 1378 ms |
| [Reckless](http://github.com/mattiasflodin/reckless) | 2.72 | 1471 ms |
| [XTR](https://github.com/choll/xtr) | 2.61 | 1534 ms |![throughput_chart.webp](docs%2Fcharts%2Fthroughput_chart.webp)
### Compilation Time
Compile times are measured using `clang 15` and for `Release` build.
Below, you can find the additional headers that the library will include when you need to log, following
the [recommended_usage](https://github.com/odygrd/quill/blob/master/examples/recommended_usage/recommended_usage.cpp)
example![quill_v5_1_compiler_profile.speedscope.png](docs%2Fquill_v5_1_compiler_profile.speedscope.png)
There is also a compile-time benchmark measuring the compilation time of 2000 auto-generated log statements with
various arguments. You can find
it [here](https://github.com/odygrd/quill/blob/master/benchmarks/compile_time/compile_time_bench.cpp). It takes
approximately 30 seconds to compile.![quill_v5_1_compiler_bench.speedscope.png](docs%2Fquill_v5_1_compiler_bench.speedscope.png)
### Verdict
Quill excels in hot path latency benchmarks and supports high throughput, offering a rich set of features that outshines
other logging libraries.The human-readable log files facilitate easier debugging and analysis. While initially larger, they compress
efficiently, with the size difference between human-readable and binary logs becoming minimal once zipped.For example, for the same amount of messages:
```
ms_binlog_backend_total_time.blog (binary log): 177 MB
ms_binlog_backend_total_time.zip (zipped binary log): 35 MB
``````
quill_backend_total_time.log (human-readable log): 448 MB
quill_backend_total_time.zip (zipped human-readable log): 47 MB
```If Quill were not available, MS BinLog would be a strong alternative. It delivers great latency on the hot path and
generates smaller binary log files. However, the binary logs necessitate offline processing with additional tools, which
can be less convenient.## 𧩠Usage
```c++
#include "quill/Backend.h"
#include "quill/Frontend.h"
#include "quill/LogMacros.h"
#include "quill/Logger.h"
#include "quill/sinks/ConsoleSink.h"
#include "quill/std/Array.h"#include
#includeint main()
{
// Backend
quill::BackendOptions backend_options;
quill::Backend::start(backend_options);// Frontend
auto console_sink = quill::Frontend::create_or_get_sink("sink_id_1");
quill::Logger* logger = quill::Frontend::create_or_get_logger("root", std::move(console_sink));// Change the LogLevel to print everything
logger->set_log_level(quill::LogLevel::TraceL3);// A log message with number 123
int a = 123;
std::string l = "log";
LOG_INFO(logger, "A {} message with number {}", l, a);// libfmt formatting language is supported 3.14e+00
double pi = 3.141592653589793;
LOG_INFO(logger, "libfmt formatting language is supported {:.2e}", pi);// Logging STD types is supported [1, 2, 3]
std::array arr = {1, 2, 3};
LOG_INFO(logger, "Logging STD types is supported {}", arr);// Logging STD types is supported [arr: [1, 2, 3]]
LOGV_INFO(logger, "Logging STD types is supported", arr);// A message with two variables [a: 123, b: 3.17]
double b = 3.17;
LOGV_INFO(logger, "A message with two variables", a, b);for (uint32_t i = 0; i < 10; ++i)
{
// Will only log the message once per second
LOG_INFO_LIMIT(std::chrono::seconds{1}, logger, "A {} message with number {}", l, a);
LOGV_INFO_LIMIT(std::chrono::seconds{1}, logger, "A message with two variables", a, b);
}LOG_TRACE_L3(logger, "Support for floats {:03.2f}", 1.23456);
LOG_TRACE_L2(logger, "Positional arguments are {1} {0} ", "too", "supported");
LOG_TRACE_L1(logger, "{:>30}", std::string_view {"right aligned"});
LOG_DEBUG(logger, "Debugging foo {}", 1234);
LOG_INFO(logger, "Welcome to Quill!");
LOG_WARNING(logger, "A warning message.");
LOG_ERROR(logger, "An error message. error code {}", 123);
LOG_CRITICAL(logger, "A critical error.");
}
```### Output
![example_output.png](docs%2Fexample_output.png)
### External CMake
#### Building and Installing Quill
To get started with Quill, clone the repository and install it using CMake:
```bash
git clone http://github.com/odygrd/quill.git
mkdir cmake_build
cd cmake_build
cmake ..
make install
```- **Custom Installation**: Specify a custom directory with `-DCMAKE_INSTALL_PREFIX=/path/to/install/dir`.
- **Build Examples**: Include examples with `-DQUILL_BUILD_EXAMPLES=ON`.Next, add Quill to your project using `find_package()`:
```cmake
find_package(quill REQUIRED)
target_link_libraries(your_target PUBLIC quill::quill)
```#### Sample Directory Structure
Organize your project directory like this:
```
my_project/
βββ CMakeLists.txt
βββ main.cpp
```#### Sample CMakeLists.txt
Hereβs a sample `CMakeLists.txt` to get you started:
```cmake
# If Quill is in a non-standard directory, specify its path.
set(CMAKE_PREFIX_PATH /path/to/quill)# Find and link the Quill library.
find_package(quill REQUIRED)
add_executable(example main.cpp)
target_link_libraries(example PUBLIC quill::quill)
```### Embedded CMake
For a more integrated approach, embed Quill directly into your project:
#### Sample Directory Structure
```
my_project/
βββ quill/ # Quill repo folder
βββ CMakeLists.txt
βββ main.cpp
```#### Sample CMakeLists.txt
Use this `CMakeLists.txt` to include Quill directly:
```cmake
cmake_minimum_required(VERSION 3.1.0)
project(my_project)set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)add_subdirectory(quill)
add_executable(my_project main.cpp)
target_link_libraries(my_project PUBLIC quill::quill)
```### Android NDK
Building Quill for Android? Add this flag during configuration:
```bash
-DQUILL_NO_THREAD_NAME_SUPPORT:BOOL=ON
```### Meson
#### Using WrapDB
Easily integrate Quill with Mesonβs `wrapdb`:
```bash
meson wrap install quill
```#### Manual Integration
Copy the repository contents to your `subprojects` directory and add the following to your `meson.build`:
```meson
quill = subproject('quill')
quill_dep = quill.get_variable('quill_dep')
my_build_target = executable('name', 'main.cpp', dependencies : [quill_dep], install : true)
```### Bazel
#### Using Blzmod
Quill is available on `BLZMOD` for easy integration.
#### Manual Integration
For manual setup, add Quill to your `BUILD.bazel` file like this:
```bazel
cc_binary(name = "app", srcs = ["main.cpp"], deps = ["//quill_path:quill"])
```## π Design
### Frontend (caller-thread)
When invoking a `LOG_` macro:
1. Creates a static constexpr metadata object to store `Metadata` such as the format string and source location.
2. Pushes the data SPSC lock-free queue. For each log message, the following variables are pushed
| Variable | Description |
|------------|:--------------------------------------------------------------------------------------------------------------:|
| timestamp | Current timestamp |
| Metadata* | Pointer to metadata information |
| Logger* | Pointer to the logger instance |
| DecodeFunc | A pointer to a templated function containing all the log message argument types, used for decoding the message |
| Args... | A serialized binary copy of each log message argument that was passed to the `LOG_` macro |### Backend
Consumes each message from the SPSC queue, retrieves all the necessary information and then formats the message.
Subsequently, forwards the log message to all Sinks associated with the Logger.![design.jpg](docs%2Fdesign.jpg)
## π¨ Caveats
Quill may not work well with `fork()` since it spawns a background thread and `fork()` doesn't work well with
multithreading.If your application uses `fork()` and you want to log in the child processes as well, you should call `quill::start()`
after the `fork()` call. Additionally, you should ensure that you write to different files in the parent and child
processes to avoid conflicts.For example :
```c++
#include "quill/Backend.h"
#include "quill/Frontend.h"
#include "quill/LogMacros.h"
#include "quill/Logger.h"
#include "quill/sinks/FileSink.h"int main()
{
// DO NOT CALL THIS BEFORE FORK
// quill::Backend::start();if (fork() == 0)
{
quill::Backend::start();
// Get or create a handler to the file - Write to a different file
auto file_sink = quill::Frontend::create_or_get_sink(
"child.log");
quill::Logger* logger = quill::Frontend::create_or_get_logger("root", std::move(file_sink));QUILL_LOG_INFO(logger, "Hello from Child {}", 123);
}
else
{
quill::Backend::start();
// Get or create a handler to the file - Write to a different file
auto file_sink = quill::Frontend::create_or_get_sink(
"parent.log");
quill::Logger* logger = quill::Frontend::create_or_get_logger("root", std::move(file_sink));
QUILL_LOG_INFO(logger, "Hello from Parent {}", 123);
}
}
```## π License
Quill is licensed under the [MIT License](http://opensource.org/licenses/MIT)
Quill depends on third party libraries with separate copyright notices and license terms.
Your use of the source code for these subcomponents is subject to the terms and conditions of the following licenses.- ([MIT License](http://opensource.org/licenses/MIT)) [{fmt}](http://github.com/fmtlib/fmt/blob/master/LICENSE.rst)
- ([MIT License](http://opensource.org/licenses/MIT)) [doctest](http://github.com/onqtam/doctest/blob/master/LICENSE.txt)