quill
PatternFormatterOptions.h
1 
7 #pragma once
8 
9 #include "quill/core/Attributes.h"
10 #include "quill/core/Common.h"
11 
12 #include <limits>
13 #include <string>
14 
15 QUILL_BEGIN_NAMESPACE
16 
24 {
25 public:
26  /***/
27  explicit PatternFormatterOptions(std::string format_pattern =
28  "%(time) [%(thread_id)] %(short_source_location:<28) "
29  "LOG_%(log_level:<9) %(logger:<12) %(message)",
30  std::string timestamp_pattern = "%H:%M:%S.%Qns",
31  Timezone timestamp_timezone = Timezone::LocalTime,
33  char pattern_suffix = '\n')
34  : format_pattern(static_cast<std::string&&>(format_pattern)),
35  timestamp_pattern(static_cast<std::string&&>(timestamp_pattern)),
39  {
40  }
41 
68  std::string format_pattern{
69  "%(time) [%(thread_id)] %(short_source_location:<28) LOG_%(log_level:<9) %(logger:<12) "
70  "%(message)"};
71 
81  std::string timestamp_pattern{"%H:%M:%S.%Qns"};
82 
94 
112  std::string_view (*process_function_name)(char const*){nullptr};
113 
119  Timezone timestamp_timezone{Timezone::LocalTime};
120 
129 
139 
147  char pattern_suffix{'\n'};
148 
153  static constexpr char NO_SUFFIX = static_cast<char>(-1);
154 
155  /***/
156  bool operator==(PatternFormatterOptions const& other) const noexcept
157  {
158  return format_pattern == other.format_pattern && timestamp_pattern == other.timestamp_pattern &&
159  source_location_path_strip_prefix == other.source_location_path_strip_prefix &&
160  timestamp_timezone == other.timestamp_timezone && process_function_name == other.process_function_name &&
161  add_metadata_to_multi_line_logs == other.add_metadata_to_multi_line_logs &&
162  source_location_remove_relative_paths == other.source_location_remove_relative_paths &&
163  pattern_suffix == other.pattern_suffix;
164  }
165 
166  /***/
167  bool operator!=(PatternFormatterOptions const& other) const noexcept { return !(*this == other); }
168 };
169 
170 QUILL_END_NAMESPACE
static constexpr char NO_SUFFIX
Special value to indicate no pattern suffix should be appended Using -1 cast to char ensures this val...
Definition: PatternFormatterOptions.h:153
std::string timestamp_pattern
The format pattern for timestamps.
Definition: PatternFormatterOptions.h:81
Timezone timestamp_timezone
The timezone to use for timestamps.
Definition: PatternFormatterOptions.h:119
bool add_metadata_to_multi_line_logs
Whether to add metadata to each line of multi-line log messages.
Definition: PatternFormatterOptions.h:128
Configuration options for the PatternFormatter.
Definition: PatternFormatterOptions.h:23
std::string_view(* process_function_name)(char const *)
Function pointer for custom processing of detailed function names for %(caller_function) ...
Definition: PatternFormatterOptions.h:112
char pattern_suffix
Character to append at the end of each formatted log pattern.
Definition: PatternFormatterOptions.h:147
bool source_location_remove_relative_paths
Whether to remove relative path components from source location paths.
Definition: PatternFormatterOptions.h:138
std::string format_pattern
The format pattern for log messages.
Definition: PatternFormatterOptions.h:68
std::string source_location_path_strip_prefix
Sets a path prefix to be stripped from source location paths.
Definition: PatternFormatterOptions.h:93