CppLogging 1.0.5.0
C++ Logging Library
Loading...
Searching...
No Matches
record.h
Go to the documentation of this file.
1
9#ifndef CPPLOGGING_RECORD_H
10#define CPPLOGGING_RECORD_H
11
12#include "logging/level.h"
13#include "string/format.h"
14#include "threads/thread.h"
15
16#include <string>
17#include <vector>
18
19namespace CppLogging {
20
22
36class Record
37{
38public:
40 uint64_t timestamp;
42 uint64_t thread;
46 std::string logger;
48 std::string message;
50 std::vector<uint8_t> buffer;
51
53 std::vector<uint8_t> raw;
54
55 Record();
56 Record(const Record&) = default;
57 Record(Record&&) = default;
58 ~Record() = default;
59
60 Record& operator=(const Record&) = default;
61 Record& operator=(Record&&) = default;
62
64 bool IsFormatStored() const noexcept { return !buffer.empty(); }
65
67 template <typename... T>
68 Record& Format(fmt::format_string<T...> pattern, T&&... args);
69
71 template <typename... T>
72 Record& StoreFormat(fmt::format_string<T...> pattern, T&&... args);
73
75 template <typename Arg>
76 Record& StoreCustom(const Arg& arg);
77 template <typename... Args>
78 Record& StoreCustomFormat(std::string_view pattern, Args&&... args);
79
81 size_t StoreListBegin();
82 template <typename... Args>
83 Record& StoreList(Args&&... args);
84 template <typename... Args>
85 Record& StoreListFormat(std::string_view pattern, Args&&... args);
86 Record& StoreListEnd(size_t begin);
87
89 std::string RestoreFormat() const { return RestoreFormat(message, buffer, 0, buffer.size()); }
90
92 static std::string RestoreFormat(std::string_view pattern, const std::vector<uint8_t>& buffer, size_t offset, size_t size);
93
95 void Clear();
96
98 void swap(Record& record) noexcept;
99 friend void swap(Record& record1, Record& record2) noexcept;
100};
101
102} // namespace CppLogging
103
104#include "record.inl"
105
106#endif // CPPLOGGING_RECORD_H
Logging record.
Definition record.h:37
Record & operator=(const Record &)=default
Record & operator=(Record &&)=default
void Clear()
Clear logging record.
Definition record.inl:449
Record & StoreListEnd(size_t begin)
Definition record.inl:441
friend void swap(Record &record1, Record &record2) noexcept
Definition record.inl:472
std::string RestoreFormat() const
Restore format message and its arguments.
Definition record.h:89
Level level
Level of the logging record.
Definition record.h:44
std::vector< uint8_t > raw
Record content after layout.
Definition record.h:53
std::string message
Message of the logging record.
Definition record.h:48
Record & StoreCustomFormat(std::string_view pattern, Args &&... args)
Definition record.inl:386
uint64_t thread
Thread Id of the logging record.
Definition record.h:42
std::string logger
Logger name of the logging record.
Definition record.h:46
std::vector< uint8_t > buffer
Buffer of the logging record.
Definition record.h:50
Record(const Record &)=default
Record & StoreListFormat(std::string_view pattern, Args &&... args)
Definition record.inl:436
Record & StoreCustom(const Arg &arg)
Store custom format message and its arguments.
Definition record.inl:377
Record(Record &&)=default
size_t StoreListBegin()
Store list format message.
Definition record.inl:415
bool IsFormatStored() const noexcept
Is the record contains stored format message and its arguments.
Definition record.h:64
Record & Format(fmt::format_string< T... > pattern, T &&... args)
Format message and its arguments.
Definition record.inl:361
uint64_t timestamp
Timestamp of the logging record.
Definition record.h:40
Record & StoreList(Args &&... args)
Definition record.inl:427
Record & StoreFormat(fmt::format_string< T... > pattern, T &&... args)
Store format message and its arguments.
Definition record.inl:368
Logging level definition.
C++ Logging project definitions.
Definition appender.h:15
Level
Logging level.
Definition level.h:18
Logging record inline implementation.