Macro-Free Mode¶
The library provides a macro-free mode that allows logging using functions instead of macros. While the macro mode remains the main and recommended approach for logging, the macro-free mode offers an alternative with cleaner code in some scenarios, at the cost of additional overhead.
The macro-free mode is implemented using compiler built-ins (__builtin_FILE(), __builtin_FUNCTION(), __builtin_LINE()) which may vary by compiler.
Performance Trade-offs¶
The macro-free approach comes with performance implications:
Higher Latency: Format metadata isn’t available at compile time, requiring additional runtime copying of metadata to the backend thread
Always-Evaluated Arguments: Unlike macros which skip evaluation for disabled log levels, arguments to these functions are always evaluated
No Compile-Time Removal: Cannot be completely compiled out with
QUILL_COMPILE_ACTIVE_LOG_LEVEL_<LEVEL>as macros canBackend Thread Impact: Reduced throughput in the backend due to runtime metadata storage and processing
Additional Safety Checks: The macro-free functions perform a runtime check for nullptr logger. This can be useful in cases where a user might forget to initialize a logger or intentionally wants logging calls to become no-ops when the logger is null. (Note that there are also multiple ways to achieve no-op logging with macros, e.g., by setting the log level to None)
For performance-critical logging paths, the macro-based logging interface is recommended.
Available Functions¶
The following logging functions are available in the macro-free mode:
quill::tracel3(logger, fmt, args...)- Trace level 3 (most detailed)quill::tracel2(logger, fmt, args...)- Trace level 2quill::tracel1(logger, fmt, args...)- Trace level 1quill::debug(logger, fmt, args...)- Debug levelquill::info(logger, fmt, args...)- Information levelquill::notice(logger, fmt, args...)- Notice levelquill::warning(logger, fmt, args...)- Warning levelquill::error(logger, fmt, args...)- Error levelquill::critical(logger, fmt, args...)- Critical levelquill::backtrace(logger, fmt, args...)- Backtrace level
Each function also accepts a quill::Tags object as an optional parameter after the logger.
Named placeholders (e.g., {name} instead of {}) work the same way as with LOG_ macros.
See Named Placeholders for details.
Usage¶
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 | |