12 : timestamp(CppCommon::Timestamp::utc()),
13 thread(CppCommon::Thread::CurrentThreadId()),
54 uint8_t value = argument;
57 size_t size =
sizeof(value);
59 std::memcpy(record.
buffer.data() + record.
buffer.size() - size, &value, size);
67 uint8_t value = argument;
70 size_t size =
sizeof(value);
72 std::memcpy(record.
buffer.data() + record.
buffer.size() - size, &value, size);
80 uint32_t value = argument;
83 size_t size =
sizeof(value);
85 std::memcpy(record.
buffer.data() + record.
buffer.size() - size, &value, size);
94 size_t size =
sizeof(argument);
96 std::memcpy(record.
buffer.data() + record.
buffer.size() - size, &argument, size);
105 size_t size =
sizeof(argument);
107 std::memcpy(record.
buffer.data() + record.
buffer.size() - size, &argument, size);
116 size_t size =
sizeof(argument);
118 std::memcpy(record.
buffer.data() + record.
buffer.size() - size, &argument, size);
128 size_t size =
sizeof(argument);
130 std::memcpy(record.
buffer.data() + record.
buffer.size() - size, &argument, size);
139 size_t size =
sizeof(argument);
141 std::memcpy(record.
buffer.data() + record.
buffer.size() - size, &argument, size);
150 size_t size =
sizeof(argument);
152 std::memcpy(record.
buffer.data() + record.
buffer.size() - size, &argument, size);
161 size_t size =
sizeof(argument);
163 std::memcpy(record.
buffer.data() + record.
buffer.size() - size, &argument, size);
172 size_t size =
sizeof(argument);
174 std::memcpy(record.
buffer.data() + record.
buffer.size() - size, &argument, size);
177 #if defined(__APPLE__)
183 uint64_t arg = argument;
189 size_t size =
sizeof(arg);
190 record.buffer.resize(record.buffer.size() + size);
191 std::memcpy(record.buffer.data() + record.buffer.size() - size, &arg, size);
202 size_t size =
sizeof(argument);
204 std::memcpy(record.
buffer.data() + record.
buffer.size() - size, &argument, size);
213 size_t size =
sizeof(argument);
215 std::memcpy(record.
buffer.data() + record.
buffer.size() - size, &argument, size);
223 uint32_t length = (uint32_t)std::strlen(argument);
226 size_t size =
sizeof(length);
228 std::memcpy(record.
buffer.data() + record.
buffer.size() - size, &length, size);
233 std::memcpy(record.
buffer.data() + record.
buffer.size() - size, argument, size);
241 uint32_t length = (uint32_t)argument.length();
244 size_t size =
sizeof(length);
246 std::memcpy(record.
buffer.data() + record.
buffer.size() - size, &length, size);
251 std::memcpy(record.
buffer.data() + record.
buffer.size() - size, argument.data(), size);
259 uint32_t length = (uint32_t)argument.length();
262 size_t size =
sizeof(length);
264 std::memcpy(record.
buffer.data() + record.
buffer.size() - size, &length, size);
269 std::memcpy(record.
buffer.data() + record.
buffer.size() - size, argument.data(), size);
272 template <
typename T>
278 uint64_t value = (uint64_t)argument;
281 size_t size =
sizeof(value);
283 std::memcpy(record.
buffer.data() + record.
buffer.size() - size, &value, size);
286 template <
typename T>
292 uint64_t value = (uint64_t)argument;
295 size_t size =
sizeof(value);
297 std::memcpy(record.
buffer.data() + record.
buffer.size() - size, &value, size);
300 template <
typename T>
306 uint32_t length = (uint32_t)strlen(argument.name);
309 size_t size =
sizeof(length);
311 std::memcpy(record.
buffer.data() + record.
buffer.size() - size, &length, size);
316 std::memcpy(record.
buffer.data() + record.
buffer.size() - size, argument.name, size);
321 #if FMT_USE_NONTYPE_TEMPLATE_ARGS
323 template <
typename T,
typename Char,
size_t N, fmt::detail_exported::fixed_
string<Char, N> Str>
324 inline void SerializeArgument(Record& record,
const fmt::detail::statically_named_arg<T, Char, N, Str>& argument)
329 uint32_t length = (uint32_t)strlen(argument.name);
332 size_t size =
sizeof(length);
333 record.buffer.resize(record.buffer.size() + size);
334 std::memcpy(record.buffer.data() + record.buffer.size() - size, &length, size);
338 record.buffer.resize(record.buffer.size() + size);
339 std::memcpy(record.buffer.data() + record.buffer.size() - size, argument.name, size);
346 template <
typename T>
353 template <
typename T,
typename... Args>
360 template <
typename... T>
363 message = CppCommon::format(pattern, std::forward<T>(args)...);
367 template <
typename... T>
370 fmt::string_view view = pattern;
371 message.assign(view.begin(), view.end());
376 template <
typename Arg>
385 template <
typename... Args>
391 size_t offset =
buffer.size();
394 uint32_t length = (uint32_t)pattern.size();
397 size_t size =
sizeof(length);
399 std::memcpy(
buffer.data() +
buffer.size() - size, &length, size);
404 std::memcpy(
buffer.data() +
buffer.size() - size, pattern.data(), size);
409 size =
buffer.size() - offset;
410 std::memcpy(
buffer.data() + offset, &size,
sizeof(uint32_t));
420 size_t offset =
buffer.size();
426 template <
typename... Args>
435 template <
typename... Args>
443 size_t size =
buffer.size() - begin;
444 std::memcpy(
buffer.data() + begin, &size,
sizeof(uint32_t));
463 swap(timestamp, record.timestamp);
464 swap(thread, record.thread);
465 swap(level, record.level);
466 swap(logger, record.logger);
467 swap(message, record.message);
468 swap(buffer, record.buffer);
469 swap(raw, record.raw);
474 record1.swap(record2);
void swap(Record &record) noexcept
Swap two instances.
void Clear()
Clear logging record.
Record & StoreListEnd(size_t begin)
Level level
Level of the logging record.
std::vector< uint8_t > raw
Record content after layout.
std::string message
Message of the logging record.
Record & StoreCustomFormat(std::string_view pattern, Args &&... args)
uint64_t thread
Thread Id of the logging record.
std::string logger
Logger name of the logging record.
std::vector< uint8_t > buffer
Buffer of the logging record.
Record & StoreListFormat(std::string_view pattern, Args &&... args)
Record & StoreCustom(const Arg &arg)
Store custom format message and its arguments.
size_t StoreListBegin()
Store list format message.
Record & Format(fmt::format_string< T... > pattern, T &&... args)
Format message and its arguments.
uint64_t timestamp
Timestamp of the logging record.
Record & StoreList(Args &&... args)
Record & StoreFormat(fmt::format_string< T... > pattern, T &&... args)
Store format message and its arguments.
C++ Logging project definitions.
void swap(Record &record1, Record &record2) noexcept
void SerializeArgument(Record &record)