Logger System 0.1.3
High-performance C++20 thread-safe logging system with asynchronous capabilities
Loading...
Searching...
No Matches
kcenon::logger::source_location Struct Reference

Source code location information for debugging. More...

#include <log_entry.h>

Collaboration diagram for kcenon::logger::source_location:
Collaboration graph

Public Member Functions

 source_location (const std::string &f="", int l=0, const std::string &func="")
 Construct source location from std::string.
 
 source_location (const char *f="", int l=0, const char *func="")
 Construct source location from C-strings.
 

Public Attributes

small_string_256 file
 Source file path.
 
int line
 Line number in the source file.
 
small_string_128 function
 Function or method name.
 

Detailed Description

Source code location information for debugging.

Captures the source file, line number, and function name where a log message originated. This information is invaluable for debugging and tracing issues in production.

The structure uses small string optimization (SSO) to avoid heap allocations for typical file paths and function names.

Note
File paths up to 256 characters and function names up to 128 characters are stored without heap allocation.
Since
1.0.0

Definition at line 93 of file log_entry.h.

Constructor & Destructor Documentation

◆ source_location() [1/2]

kcenon::logger::source_location::source_location ( const std::string & f = "",
int l = 0,
const std::string & func = "" )
inline

Construct source location from std::string.

Parameters
fSource file path (default: empty)
lLine number (default: 0)
funcFunction name (default: empty)
Examples
/home/runner/work/logger_system/logger_system/include/kcenon/logger/interfaces/log_entry.h.

Definition at line 118 of file log_entry.h.

119 : file(f), line(l), function(func) {}
small_string_128 function
Function or method name.
Definition log_entry.h:110
small_string_256 file
Source file path.
Definition log_entry.h:98
int line
Line number in the source file.
Definition log_entry.h:104

◆ source_location() [2/2]

kcenon::logger::source_location::source_location ( const char * f = "",
int l = 0,
const char * func = "" )
inline

Construct source location from C-strings.

Parameters
fSource file path (default: empty)
lLine number (default: 0)
funcFunction name (default: empty)
Note
This overload avoids temporary std::string creation when using FILE and FUNCTION macros.

Definition at line 130 of file log_entry.h.

131 : file(f), line(l), function(func) {}

Member Data Documentation

◆ file

small_string_256 kcenon::logger::source_location::file

Source file path.

Uses small_string_256 for efficient storage of file paths

Examples
/home/runner/work/logger_system/logger_system/include/kcenon/logger/interfaces/log_entry.h.

Definition at line 98 of file log_entry.h.

◆ function

small_string_128 kcenon::logger::source_location::function

Function or method name.

Uses small_string_128 for efficient storage of function names

Examples
/home/runner/work/logger_system/logger_system/include/kcenon/logger/interfaces/log_entry.h.

Definition at line 110 of file log_entry.h.

◆ line

int kcenon::logger::source_location::line

Line number in the source file.

Set to 0 if line information is not available

Examples
/home/runner/work/logger_system/logger_system/include/kcenon/logger/interfaces/log_entry.h.

Definition at line 104 of file log_entry.h.


The documentation for this struct was generated from the following file: