18 const uint32_t FNV_PRIME = 16777619u;
19 const uint32_t OFFSET_BASIS = 2166136261u;
21 uint32_t hash = OFFSET_BASIS;
22 for (
size_t i = 0; i < message.size(); ++i)
33 uint32_t size = (uint32_t)(
sizeof(uint64_t) +
sizeof(uint64_t) +
sizeof(
Level) +
sizeof(uint32_t) +
sizeof(uint32_t) +
sizeof(uint32_t) + record.
buffer.size());
36 record.
raw.resize(
sizeof(uint32_t) + size + 1);
39 uint8_t* buffer = record.
raw.data();
42 std::memcpy(buffer, &size,
sizeof(uint32_t));
43 buffer +=
sizeof(uint32_t);
44 std::memcpy(buffer, &record.
timestamp,
sizeof(uint64_t));
45 buffer +=
sizeof(uint64_t);
46 std::memcpy(buffer, &record.
thread,
sizeof(uint64_t));
47 buffer +=
sizeof(uint64_t);
48 std::memcpy(buffer, &record.
level,
sizeof(
Level));
49 buffer +=
sizeof(
Level);
53 std::memcpy(buffer, &logger_hash,
sizeof(uint32_t));
54 buffer +=
sizeof(uint32_t);
58 std::memcpy(buffer, &message_hash,
sizeof(uint32_t));
59 buffer +=
sizeof(uint32_t);
62 uint32_t buffer_size = (uint32_t)record.
buffer.size();
63 std::memcpy(buffer, &buffer_size,
sizeof(uint32_t));
64 buffer +=
sizeof(uint32_t);
65 std::memcpy(buffer, record.
buffer.data(), record.
buffer.size());
66 buffer += record.
buffer.size();
static uint32_t Hash(std::string_view message)
Hash the given string message using FNV-1a hashing algorithm.
void LayoutRecord(Record &record) override
Layout the given logging record into a raw buffer.
Level level
Level of the logging record.
std::vector< uint8_t > raw
Record content after layout.
std::string message
Message of the logging record.
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.
uint64_t timestamp
Timestamp of the logging record.
C++ Logging project definitions.