New Features
-
There is a new macro-free mode that allows logging without macros. You have two options: either
#include "quill/LogMacros.h"
or#include "quill/LogFunctions.h"
. The macro mode still remains the recommended and main method for logging. The new macro-free log has higher overhead than using macros. To use the macro-free mode, for example:quill::debug(logger, "A {} message with number {}", "test", 123);
See macro-free mode documentation here for details.
-
Added
BinaryDataDeferredFormatCodec
for efficient binary data logging. This codec allows efficient logging of variable-sized binary data by copying the raw bytes on the hot path and deferring the formatting to the backend thread. This is particularly useful for logging binary protocol messages (like SBE or custom binary formats), network packets, and raw binary data without impacting application performance. See the example sbe_logging and binary_protocol_logging for details. For documentation, see here. -
The immediate flush feature has been enhanced to support interval-based flushing and moved to runtime. This feature helps with debugging by ensuring log statements are flushed to the sink, blocking the caller thread. (#660)
-
Added the
QUILL_DISABLE_FILE_INFO
preprocessor flag and CMake option. This disables__FILE__
and__LINE__
information in log statements at compile time when location-related patterns (%(file_name)
,%(line_number)
,%(short_source_location)
,%(source_location)
) are not needed in thePatternFormatter
. This removes embedded source path strings from built binaries from the security viewpoint. -
Added the
QUILL_DETAILED_FUNCTION_NAME
CMake option. When enabled, this option uses compiler-specific detailed function signatures (such as__PRETTY_FUNCTION__
on GCC/Clang or__FUNCSIG__
on MSVC) instead of the standard__FUNCTION__
in log macros. This provides more complete function information, including return types, namespaces, and parameter types. This option is only relevant when%(caller_function)
is used in the pattern formatter. (#785) -
Added
source_location_path_strip_prefix
option inPatternFormatterOptions
to customize the display of the%(source_location)
attribute ofPatternFormatter
. When set, any paths that contain this prefix will have the prefix and everything before it stripped from the displayed path. For example, with prefix "projects", a source location like "/home/user/projects/app/main.cpp:5" would be displayed as "app/main.cpp:5". (#772) -
Added
source_location_remove_relative_paths
option inPatternFormatterOptions
to remove relative path components from the%(source_location)
attribute ofPatternFormatter
. When enabled, relative path components like "../" are processed and removed, simplifying paths from__FILE__
which might contain relative paths like "../../../test/main.cpp". (#778) -
Added
process_function_name
customisation point inPatternFormatterOptions
. This function allows custom processing of the function signature before it's displayed in logs. This makes more sense to use whenQUILL_DETAILED_FUNCTION_NAME
is used. This provides flexibility to trim, format, or otherwise modify function signatures to improve readability in log output when using the%(caller_function)
pattern. (#785) -
Added helper macros for easy logging of user-defined types. Two new macros are available in
quill/HelperMacros.h
:QUILL_LOGGABLE_DIRECT_FORMAT(Type)
: For types that contain pointers or have lifetime dependenciesQUILL_LOGGABLE_DEFERRED_FORMAT(Type)
: For types that only contain value types and are safe to copy
Note that these macros require you to provide either an
operator<<
for your type and they are just shortcuts to existing functionality. (#777)Example usage:
class User { /* ... */ }; std::ostream& operator<<(std::ostream& os, User const& user) { /* ... */ } // For types with pointers - will format immediately QUILL_LOGGABLE_DIRECT_FORMAT(User) class Product { /* ... */ }; std::ostream& operator<<(std::ostream& os, Product const& product) { /* ... */ } // For types with only value members - can format asynchronously QUILL_LOGGABLE_DEFERRED_FORMAT(Product)
Improvements
-
Internally, refactored how runtime metadata are handled for more flexibility, providing three macros for logging with runtime metadata:
QUILL_LOG_RUNTIME_METADATA_DEEP
- Takes a deep copy offmt
,file
,function
andtags
. Most flexible
option, useful for forwarding logs from another logging library.QUILL_LOG_RUNTIME_METADATA_HYBRID
- Will take a deep copy offmt
andtags
and will takefile
and
function
as reference. This is used for the new macro-free mode.QUILL_LOG_RUNTIME_METADATA_SHALLOW
- Will take everything as reference. This is used when logging with
compile-time metadata and using, for example, a dynamic log-level such asLOG_DYNAMIC
.
-
When using a sink with overridden
PatternFormatterOptions
, the optionadd_metadata_to_multi_line_logs
will now be correctly applied at the Sink level. Previously, this option was only available and effective at the Logger levelPatternFormatter
. -
When a Sink with override
PatternFormatterOptions
is used and if no other sink exists using theLogger
PatternFormatterOptions
, then the backend thread will no longer perform a redundant format log statement. -
When using a sink with overridden
PatternFormatterOptions
, thelog_statement
that is passed to theFilter::filter()
will now be formatted based on the overridden options instead of using theLogger
PatternFormatterOptions
. -
Update bundled
libfmt
tov11.2.0
API Changes
-
If you were previously setting
QUILL_ENABLE_IMMEDIATE_FLUSH
to1
, this functionality has been moved to runtime with more flexibility. Instead of using a boolean flag, you can now specify the flush interval by callinglogger->set_immediate_flush(flush_every_n_messages)
on each logger instance. Set it to1
for per-message flushing, or to a higher value to flush after that many messages. Setting it to0
disables flushing which is the default behaviour.QUILL_ENABLE_IMMEDIATE_FLUSH
still exists as a compile-time preprocessor flag and is set to1
by default. SettingQUILL_ENABLE_IMMEDIATE_FLUSH 0
in the preprocessor will eliminate theif
branch from the hot path and disable this feature entirely, regardless of the value passed toset_immediate_flush(flush_every_n_messages)
. -
The
QUILL_LOG_RUNTIME_METADATA
macro requiresfile
,function
andfmt
to be passed aschar const*
andline_number
asuint32_t
. This is a breaking change from the previous version.