LogIt++
Header-only, macro-first C++ logging library
Loading...
Searching...
No Matches
LogRecord.hpp
Go to the documentation of this file.
1#pragma once
2#ifndef LOGIT_CPP_HEADER_LOGIT_CPP_LOGIT_UTILS_LOGRECORD_HPP_INCLUDED
3#define LOGIT_CPP_HEADER_LOGIT_CPP_LOGIT_UTILS_LOGRECORD_HPP_INCLUDED
4
7
8#include <string>
9#include <vector>
10#include <cstdint>
11#include <thread>
12
13namespace logit {
14
17 struct LogRecord {
19 const int64_t timestamp_ms;
20 const std::string file;
21 const int line;
22 const std::string function;
23 const std::string format;
24 const std::string arg_names;
25 // IMPORTANT: cache, filled by Logger::print() even for const LogRecord&
26 mutable std::vector<VariableValue> args_array;
27 std::thread::id thread_id;
28 const int logger_index;
29 const bool print_mode : 1;
30 const bool fmt_mode : 1;
31 const bool raw_mode : 1;
32#ifdef LOGIT_WITH_CONTEXT
33 const std::shared_ptr<const LogContextSnapshot> context;
34#endif
35
50 int64_t timestamp_ms,
51 const std::string& file,
52 int line,
53 const std::string& function,
54 const std::string& format,
55 const std::string& arg_names,
56 int logger_index,
57 bool print_mode,
58 bool fmt_mode = false,
59 bool raw_mode = false) :
62 file(file),
63 line(line),
67 thread_id(std::this_thread::get_id()),
72#ifdef LOGIT_WITH_CONTEXT
73 , context(capture_log_context())
74#endif
75 {
76 };
77 };
78
79}; // namespace logit
80
81#endif // LOGIT_CPP_HEADER_LOGIT_CPP_LOGIT_UTILS_LOGRECORD_HPP_INCLUDED
The primary namespace for the LogIt++ library.
LogLevel
Logging levels.
Definition enums.hpp:15
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
LogRecord(LogLevel log_level, int64_t timestamp_ms, const std::string &file, int line, const std::string &function, const std::string &format, const std::string &arg_names, int logger_index, bool print_mode, bool fmt_mode=false, bool raw_mode=false)
Constructor with argument names.
Definition LogRecord.hpp:48
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