LogIt++
Header-only, macro-first C++ logging library
Loading...
Searching...
No Matches
OtlpRecordSnapshot.hpp
Go to the documentation of this file.
1#pragma once
2#ifndef LOGIT_CPP_HEADER_LOGIT_CPP_LOGIT_LOGGERS_OTLP_OTLPRECORDSNAPSHOT_HPP_INCLUDED
3#define LOGIT_CPP_HEADER_LOGIT_CPP_LOGIT_LOGGERS_OTLP_OTLPRECORDSNAPSHOT_HPP_INCLUDED
4
7
8#include <logit/utils.hpp>
9#include <sstream>
10#include <string>
11#include <thread>
12#include <vector>
13
14namespace logit {
15
20 int64_t timestamp_ms = 0;
21 std::string file;
22 int line = 0;
23 std::string function;
24 std::string format;
25 std::string arg_names;
26 std::vector<VariableValue> args_array;
27 std::string thread_id;
28 int logger_index = -1;
29 bool print_mode = false;
30 bool fmt_mode = false;
31 bool raw_mode = false;
32 };
33
37 inline std::string otlp_thread_id_to_string(const std::thread::id& id) {
38 std::ostringstream oss;
39 oss << id;
40 return oss.str();
41 }
42
48 out.log_level = record.log_level;
49 out.timestamp_ms = record.timestamp_ms;
50 out.file = record.file;
51 out.line = record.line;
52 out.function = record.function;
53 out.format = record.format;
54 out.arg_names = record.arg_names;
55 out.args_array = record.args_array;
57 out.logger_index = record.logger_index;
58 out.print_mode = record.print_mode;
59 out.fmt_mode = record.fmt_mode;
60 out.raw_mode = record.raw_mode;
61 return out;
62 }
63
64} // namespace logit
65
66#endif // LOGIT_CPP_HEADER_LOGIT_CPP_LOGIT_LOGGERS_OTLP_OTLPRECORDSNAPSHOT_HPP_INCLUDED
The primary namespace for the LogIt++ library.
LogLevel
Logging levels.
Definition enums.hpp:15
@ LOG_LVL_TRACE
Trace level logging.
std::string otlp_thread_id_to_string(const std::thread::id &id)
Converts thread id to a portable string representation.
OtlpRecordSnapshot make_otlp_record_snapshot(const LogRecord &record)
Creates an owned snapshot from a LogRecord.
Stores log metadata and content.
Definition LogRecord.hpp:17
const std::string function
Function name.
Definition LogRecord.hpp:22
const int logger_index
Logger index (-1 to log to all).
Definition LogRecord.hpp:28
const int line
Line number in the source file.
Definition LogRecord.hpp:21
std::thread::id thread_id
ID of the logging thread.
Definition LogRecord.hpp:27
const LogLevel log_level
Log level (severity).
Definition LogRecord.hpp:18
const bool raw_mode
Flag indicating if formatter and level filters should be bypassed.
Definition LogRecord.hpp:31
const int64_t timestamp_ms
Timestamp in milliseconds.
Definition LogRecord.hpp:19
const bool fmt_mode
Flag indicating if fmt formatting should be used.
Definition LogRecord.hpp:30
const std::string file
Source file name.
Definition LogRecord.hpp:20
const std::string format
Format string for the message.
Definition LogRecord.hpp:23
std::vector< VariableValue > args_array
Argument values for the log.
Definition LogRecord.hpp:26
const std::string arg_names
Argument names for the log.
Definition LogRecord.hpp:24
const bool print_mode
Flag to determine whether arguments are printed in a raw format without special symbols.
Definition LogRecord.hpp:29
Owns LogRecord fields required after original logging call returns.
std::string format
Original message or format string.
LogLevel log_level
Log severity level.
int64_t timestamp_ms
Timestamp in milliseconds.
int line
Source line number.
std::string thread_id
Stringified std::thread::id.
std::vector< VariableValue > args_array
Structured argument values.
std::string file
Source file path.
int logger_index
Target logger index, or -1 for all.
std::string arg_names
Original argument names.
std::string function
Source function name.
bool fmt_mode
fmt formatting mode flag.
bool raw_mode
Raw log mode flag.
bool print_mode
Raw argument print mode flag.
Aggregates the public utilities module.