2#ifndef _LOGIT_SIMPLE_LOG_FORMATTER_HPP_INCLUDED
3#define _LOGIT_SIMPLE_LOG_FORMATTER_HPP_INCLUDED
22 std::string
pattern =
"[%Y-%m-%d %H:%M:%S.%e] [%ffn:%#] [%!] [thread:%t] [%l] %^%v%$";
45 void set_pattern(
const std::string& pattern,
bool json_format =
false) {
98 std::ostringstream oss;
100 instruction.apply(oss, record, dt);
112 std::ostringstream oss;
114 <<
"\"log_level\": " <<
static_cast<int>(record.
log_level) <<
", "
117 <<
"\"line\": " << record.
line <<
", "
121 <<
"\"args_array\": [";
123 for (
size_t i = 0; i < record.
args_array.size(); ++i) {
124 if (i > 0) oss <<
", ";
143 std::ostringstream oss;
144 for (
char c : input) {
146 case '"': oss <<
"\\\"";
break;
147 case '\\': oss <<
"\\\\";
break;
148 case '\b': oss <<
"\\b";
break;
149 case '\f': oss <<
"\\f";
break;
150 case '\n': oss <<
"\\n";
break;
151 case '\r': oss <<
"\\r";
break;
152 case '\t': oss <<
"\\t";
break;
154 if (
'\x00' <= c && c <=
'\x1f') {
156 << std::hex << std::setw(4) << std::setfill('0') << static_cast<int>(c);
172 std::ostringstream oss;
Header file for the pattern compiler used in log formatting.
static std::vector< FormatInstruction > compile(const std::string &pattern, CompileContext context=CompileContext::Default)
Compiles a pattern string into a list of format instructions.
The primary namespace for the LogIt++ library.
Stores log metadata and content.
const std::string function
Function name.
const int line
Line number in the source file.
std::thread::id thread_id
ID of the logging thread.
const LogLevel log_level
Log level (severity).
const int64_t timestamp_ms
Timestamp in milliseconds.
const std::string file
Source file name.
const std::string format
Format string for the message.
std::vector< VariableValue > args_array
Argument values for the log.
const std::string arg_names
Argument names for the log.