|
| void | set_level (Level level) |
| | Sets the logging verbosity (CRITICAL,ERROR,INFO,DEBUG)
|
| |
| Level | get_level () |
| | Get current verbosity level of the logger.
|
| |
| void | set_sink_file (fs::path const &path_file_sink) |
| | Sets the sink file of the logger.
|
| |
| void | set_as_fork () |
| | Marks the logger as being in a forked child process.
|
| |
| template<typename... Ts> |
| std::string | vformat (std::string_view fmt, Ts &&... ts) |
| | Workaround make_format_args only taking references.
|
| |
| template<ns_string::static_string str> |
| constexpr decltype(auto) | impl_log (Location loc) |
| | Implementation function for compile-time log level dispatch.
|
| |
Multi-level logging system with file and stdout sinks.
Thread-local logging infrastructure supporting DEBUG, INFO, WARNING, ERROR, and CRITICAL levels with automatic source location tracking. Provides dual output to log files and stdout/stderr with level-based prefixes (D::, I::, W::, E::, C::) for convenient filtering and categorization.
| void ns_log::set_as_fork |
( |
| ) |
|
|
inline |
Marks the logger as being in a forked child process.
For processes that need to explicitly indicate they are children (e.g., pipe readers forked from the parent), this function sets the logger's tracked PID to an invalid value (0) so that subsequent log messages always display the current process ID instead of file location information.
Usage Example:
pid_t pid = fork();
if (pid == 0) {
logger(
"I::Starting in child process");
}
#define logger(fmt,...)
Compile-time log level dispatch macro with automatic location capture.
void set_as_fork()
Marks the logger as being in a forked child process.
void set_sink_file(fs::path const &path_file_sink)
Sets the sink file of the logger.
Effect on Log Output:
- Before:
I::boot.cpp::50::Message (if m_pid matched current PID)
- After:
I::12345::Message (always shows current PID since m_pid=0)
Note: This is typically automatic after fork() + pthread_atfork handlers, but can be called explicitly for clarity or in special circumstances.
Definition at line 390 of file log.hpp.