Logger System 0.1.3
High-performance C++20 thread-safe logging system with asynchronous capabilities
Loading...
Searching...
No Matches
log_entry_pool.h
Go to the documentation of this file.
1// BSD 3-Clause License
2// Copyright (c) 2021-2025, 🍀☀🌕🌥 🌊
3// See the LICENSE file in the project root for full license information.
4
10#pragma once
11
13#include <memory>
14#include <string>
15#include <chrono>
16
18
23 common::interfaces::log_level level{common::interfaces::log_level::info};
24 std::string message;
25 std::string file_path;
27 std::string function_name;
28 std::chrono::system_clock::time_point timestamp;
29
33 void reset() {
34 level = common::interfaces::log_level::info;
35 message.clear();
36 file_path.clear();
37 line_number = 0;
38 function_name.clear();
39 timestamp = std::chrono::system_clock::now();
40 }
41
45 void initialize(common::interfaces::log_level lvl,
46 const std::string& msg,
47 const std::string& file,
48 int line,
49 const std::string& func) {
50 level = lvl;
51 message = msg;
52 file_path = file;
53 line_number = line;
54 function_name = func;
55 timestamp = std::chrono::system_clock::now();
56 }
57
63 if (!file_path.empty() || line_number != 0 || !function_name.empty()) {
65 }
66 return entry;
67 }
68};
69
70} // namespace kcenon::logger::memory::log_entry_pool
Data structures for representing log entries and source locations kcenon.
Represents a single log entry with all associated metadata.
Definition log_entry.h:155
std::optional< source_location > location
Optional source code location information.
Definition log_entry.h:183
Pooled log entry structure optimized for reuse.
void reset()
Reset entry for reuse.
std::chrono::system_clock::time_point timestamp
std::string file_path
int line_number
void initialize(common::interfaces::log_level lvl, const std::string &msg, const std::string &file, int line, const std::string &func)
Initialize with log data.
std::string message
log_entry to_log_entry() const
Convert to standard log_entry.
std::string function_name
common::interfaces::log_level level
Source code location information for debugging.
Definition log_entry.h:93