quill
PatternFormatterOptions.h
1 
7 #pragma once
8 
9 #include "quill/core/Attributes.h"
10 #include "quill/core/Common.h"
11 
12 #include <string>
13 
14 QUILL_BEGIN_NAMESPACE
15 
16 QUILL_BEGIN_EXPORT
17 
25 {
26 private:
27  static constexpr char const* default_format_pattern{
28  "%(time) [%(thread_id)] %(short_source_location:<28) LOG_%(log_level:<9) %(logger:<12) "
29  "%(message)%(mdc)"};
30 
31 public:
32  /***/
33  explicit PatternFormatterOptions(std::string format_pattern = default_format_pattern,
34  std::string timestamp_pattern = "%H:%M:%S.%Qns",
35  Timezone timestamp_timezone = Timezone::LocalTime,
36  bool add_metadata_to_multi_line_logs = true, char pattern_suffix = '\n')
37  : format_pattern(static_cast<std::string&&>(format_pattern)),
38  timestamp_pattern(static_cast<std::string&&>(timestamp_pattern)),
42  {
43  }
44 
72  std::string format_pattern{default_format_pattern};
73 
83  std::string timestamp_pattern{"%H:%M:%S.%Qns"};
84 
98 
116  std::string_view (*process_function_name)(char const*){nullptr};
117 
123  Timezone timestamp_timezone{Timezone::LocalTime};
124 
133 
143 
151  char pattern_suffix{'\n'};
152 
157  static constexpr char NO_SUFFIX = static_cast<char>(-1);
158 
159  /***/
160  bool operator==(PatternFormatterOptions const& other) const
161  {
168  }
169 
170  /***/
171  bool operator!=(PatternFormatterOptions const& other) const { return !(*this == other); }
172 };
173 
174 QUILL_END_EXPORT
175 
176 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:157
std::string timestamp_pattern
The format pattern for timestamps.
Definition: PatternFormatterOptions.h:83
Timezone timestamp_timezone
The timezone to use for timestamps.
Definition: PatternFormatterOptions.h:123
bool add_metadata_to_multi_line_logs
Whether to add metadata to each line of multi-line log messages.
Definition: PatternFormatterOptions.h:132
Configuration options for the PatternFormatter.
Definition: PatternFormatterOptions.h:24
std::string_view(* process_function_name)(char const *)
Function pointer for custom processing of detailed function names for %(caller_function) ...
Definition: PatternFormatterOptions.h:116
char pattern_suffix
Character to append at the end of each formatted log pattern.
Definition: PatternFormatterOptions.h:151
bool source_location_remove_relative_paths
Whether to remove relative path components from source location paths.
Definition: PatternFormatterOptions.h:142
std::string format_pattern
The format pattern for log messages.
Definition: PatternFormatterOptions.h:72
std::string source_location_path_strip_prefix
Sets a path prefix to be stripped from source location paths.
Definition: PatternFormatterOptions.h:97