quill
|
Configuration options for the PatternFormatter. More...
#include <PatternFormatterOptions.h>
Public Member Functions | |
PatternFormatterOptions (std::string format_pattern="%(time) [%(thread_id)] %(short_source_location:<28) " "LOG_%(log_level:<9) %(logger:<12) %(message)", std::string timestamp_pattern="%H:%M:%S.%Qns", Timezone timestamp_timezone=Timezone::LocalTime, bool add_metadata_to_multi_line_logs=true) | |
bool | operator== (PatternFormatterOptions const &other) const noexcept |
bool | operator!= (PatternFormatterOptions const &other) const noexcept |
Public Attributes | |
std::string | format_pattern |
The format pattern for log messages. More... | |
std::string | timestamp_pattern {"%H:%M:%S.%Qns"} |
The format pattern for timestamps. More... | |
std::string | source_location_path_strip_prefix {} |
Sets a path prefix to be stripped from source location paths. More... | |
std::string_view(* | process_function_name )(char const *) |
Function pointer for custom processing of detailed function names for %(caller_function) More... | |
Timezone | timestamp_timezone {Timezone::LocalTime} |
The timezone to use for timestamps. More... | |
bool | add_metadata_to_multi_line_logs {true} |
Whether to add metadata to each line of multi-line log messages. More... | |
bool | source_location_remove_relative_paths {false} |
Whether to remove relative path components from source location paths. More... | |
Configuration options for the PatternFormatter.
This class encapsulates the configuration options used to customize the formatting of log messages.
bool PatternFormatterOptions::add_metadata_to_multi_line_logs {true} |
Whether to add metadata to each line of multi-line log messages.
If true, ensures that metadata (e.g., timestamp, log level) is added to every line of multi-line log entries, maintaining consistency across all log outputs.
std::string PatternFormatterOptions::format_pattern |
The format pattern for log messages.
This string defines the overall structure of each log message.
It can include various placeholders that will be replaced with actual values when formatting the log message.
%(time) - Human-readable timestamp representing when the log statement was created. %(file_name) - Name of the source file where the logging call was issued. %(full_path) - Full path of the source file where the logging call was issued. %(caller_function) - Name of the function containing the logging call. %(log_level) - Textual representation of the logging level for the message. %(log_level_short_code) - Abbreviated log level name. %(line_number) - Line number in the source file where the logging call was issued. %(logger) - Name of the logger used to log the call. %(message) - The logged message itself. %(thread_id) - ID of the thread in which the logging call was made. %(thread_name) - Name of the thread. Must be set before the first log statement on that thread. %(process_id) - ID of the process in which the logging call was made. %(source_location) - Full source file path and line number as a single string. %(short_source_location) - Shortened source file name and line number as a single string. %(tags) - Additional custom tags appended to the message when _TAGS macros are used. %(named_args) - Key-value pairs appended to the message. Only applicable when the message has named args; remains empty otherwise.
|
inline |
Function pointer for custom processing of detailed function names for %(caller_function)
This is most useful when QUILL_DETAILED_FUNCTION_NAME is enabled, as it allows custom processing of the detailed function signature provided by the compiler.
Since the format of PRETTY_FUNCTION or equivalent is compiler-specific, this function allows users to implement their own parsing/formatting logic.
The function takes one parameter:
It should return a string_view representing the processed function name.
If set to nullptr (default), the logger will use the unprocessed function name as provided by the compiler.
std::string PatternFormatterOptions::source_location_path_strip_prefix {} |
Sets a path prefix to be stripped from source location paths.
When set, any source location paths that start with this prefix will have the prefix removed:
This affects only the %(source_location) attribute.
bool PatternFormatterOptions::source_location_remove_relative_paths {false} |
Whether to remove relative path components from source location paths.
If true, relative path components like "../" will be processed and removed from source location paths, simplifying the displayed path.
This affects only the %(source_location) attribute.
std::string PatternFormatterOptions::timestamp_pattern {"%H:%M:%S.%Qns"} |
The format pattern for timestamps.
This string defines how timestamps are formatted in log messages. It follows the strftime() format with additional specifiers:
Timezone PatternFormatterOptions::timestamp_timezone {Timezone::LocalTime} |
The timezone to use for timestamps.
Determines whether timestamps are formatted in local time or GMT.