Logger System
0.1.3
High-performance C++20 thread-safe logging system with asynchronous capabilities
Loading...
Searching...
No Matches
log_context.h
Go to the documentation of this file.
1
// BSD 3-Clause License
2
9
#pragma once
10
11
#include <chrono>
12
#include <string_view>
13
#include <thread>
14
15
namespace
kcenon::logger::core
{
16
17
struct
log_context {
18
std::string_view
file
{
"unknown"
};
19
int
line
{0};
20
std::string_view
function
{
"unknown"
};
21
std::thread::id
thread_id
{std::this_thread::get_id()};
22
std::chrono::time_point<std::chrono::system_clock>
timestamp
{
23
std::chrono::system_clock::now()};
24
};
25
26
inline
log_context
make_log_context
(std::string_view file,
27
int
line,
28
std::string_view function) {
29
log_context
ctx;
30
ctx.file = file;
31
ctx.line = line;
32
ctx.function = function;
33
ctx.thread_id = std::this_thread::get_id();
34
ctx.timestamp = std::chrono::system_clock::now();
35
return
ctx;
36
}
37
38
}
// namespace kcenon::logger::core
kcenon::logger::core
Definition
filtered_logger.h:19
kcenon::logger::core::make_log_context
log_context make_log_context(std::string_view file, int line, std::string_view function)
Create a log context with source location.
Definition
log_context.h:26
kcenon::logger::core::log_context
Log context containing source location information.
Definition
core.cppm:91
kcenon::logger::core::log_context::file
std::string_view file
Definition
log_context.h:18
kcenon::logger::core::log_context::function
std::string_view function
Definition
log_context.h:20
kcenon::logger::core::log_context::timestamp
std::chrono::time_point< std::chrono::system_clock > timestamp
Definition
log_context.h:22
kcenon::logger::core::log_context::thread_id
std::thread::id thread_id
Definition
log_context.h:21
kcenon::logger::core::log_context::line
int line
Definition
log_context.h:19
include
kcenon
logger
core
log_context.h
Generated by
1.12.0