|
Logger System 0.1.3
High-performance C++20 thread-safe logging system with asynchronous capabilities
|
Thread-local storage for structured logging context fields. More...
#include <log_context_scope.h>

Static Public Member Functions | |
| static void | set (const std::string &key, const std::string &value) |
| Set a string context field for the current thread. | |
| static void | set (const std::string &key, const char *value) |
| Set a C-string context field for the current thread. | |
| static void | set (const std::string &key, int64_t value) |
| Set an integer context field for the current thread. | |
| static void | set (const std::string &key, double value) |
| Set a double context field for the current thread. | |
| static void | set (const std::string &key, bool value) |
| Set a boolean context field for the current thread. | |
| static void | set (const std::string &key, const log_value &value) |
| Set a log_value context field for the current thread. | |
| static void | set_all (const log_fields &fields) |
| Set multiple context fields at once. | |
| static void | remove (const std::string &key) |
| Remove a context field for the current thread. | |
| static log_fields | get () |
| Get all context fields for the current thread. | |
| static void | clear () |
| Clear all context fields for the current thread. | |
| static bool | has_context () |
| Check if any context fields are set for the current thread. | |
| static std::optional< log_value > | get_field (const std::string &key) |
| Get a specific field value if it exists. | |
Static Private Member Functions | |
| static log_fields & | get_storage () |
| static bool & | get_has_context () |
Thread-local storage for structured logging context fields.
Provides thread-safe storage and retrieval of context fields using thread-local storage. This allows automatic context propagation within a thread without affecting other threads.
Thread-local context takes precedence over logger-level context when both are set. Fields are merged with thread-local fields overriding logger-level fields with the same key.
Definition at line 75 of file log_context_scope.h.
|
inlinestatic |
Clear all context fields for the current thread.
Definition at line 175 of file log_context_scope.h.
References get_has_context(), and get_storage().

|
inlinestaticnodiscard |
Get all context fields for the current thread.
Definition at line 165 of file log_context_scope.h.
References get_has_context(), and get_storage().

|
inlinestaticnodiscard |
Get a specific field value if it exists.
| key | Field name |
Definition at line 193 of file log_context_scope.h.
References get_has_context(), and get_storage().
Referenced by kcenon::logger::scoped_context::scoped_context(), kcenon::logger::scoped_context::scoped_context(), kcenon::logger::scoped_context::scoped_context(), and kcenon::logger::scoped_context::scoped_context().


|
inlinestaticprivate |
Definition at line 211 of file log_context_scope.h.
Referenced by clear(), get(), get_field(), has_context(), remove(), set(), set(), set(), set(), set(), set(), and set_all().

|
inlinestaticprivate |
Definition at line 206 of file log_context_scope.h.
Referenced by clear(), get(), get_field(), remove(), set(), set(), set(), set(), set(), set(), and set_all().

|
inlinestaticnodiscard |
Check if any context fields are set for the current thread.
Definition at line 184 of file log_context_scope.h.
References get_has_context().

|
inlinestatic |
Remove a context field for the current thread.
| key | Field name to remove |
Definition at line 154 of file log_context_scope.h.
References get_has_context(), and get_storage().
Referenced by kcenon::logger::scoped_context::~scoped_context().


|
inlinestatic |
Set a boolean context field for the current thread.
| key | Field name |
| value | Field value |
Definition at line 122 of file log_context_scope.h.
References get_has_context(), and get_storage().

|
inlinestatic |
Set a C-string context field for the current thread.
| key | Field name |
| value | Field value (will be converted to std::string) |
Definition at line 92 of file log_context_scope.h.
References get_has_context(), and get_storage().

|
inlinestatic |
Set a log_value context field for the current thread.
| key | Field name |
| value | Field value |
Definition at line 132 of file log_context_scope.h.
References get_has_context(), and get_storage().

|
inlinestatic |
Set a string context field for the current thread.
| key | Field name |
| value | Field value |
Definition at line 82 of file log_context_scope.h.
References get_has_context(), and get_storage().
Referenced by kcenon::logger::log_context_scope::log_context_scope(), kcenon::logger::scoped_context::scoped_context(), kcenon::logger::scoped_context::scoped_context(), kcenon::logger::scoped_context::scoped_context(), kcenon::logger::scoped_context::scoped_context(), and kcenon::logger::scoped_context::~scoped_context().


|
inlinestatic |
Set a double context field for the current thread.
| key | Field name |
| value | Field value |
Definition at line 112 of file log_context_scope.h.
References get_has_context(), and get_storage().

|
inlinestatic |
Set an integer context field for the current thread.
| key | Field name |
| value | Field value |
Definition at line 102 of file log_context_scope.h.
References get_has_context(), and get_storage().

|
inlinestatic |
Set multiple context fields at once.
| fields | Fields to set |
Definition at line 141 of file log_context_scope.h.
References get_has_context(), and get_storage().
