|
cbase 1.50.0
C/C++ Static Template
|
Implementation of the leveled logging subsystem. More...

Go to the source code of this file.
Classes | |
| struct | BaseLogCallback |
| Internal structure to hold a logging callback and its configuration. More... | |
| struct | BaseLogger |
| Internal state structure for the global logger. More... | |
Macros | |
| #define | MAX_CALLBACKS 4 |
| Maximum number of custom log callbacks supported simultaneously. | |
| #define | COLOR_TRACE "\x1b[94m" |
| #define | COLOR_DEBUG "\x1b[36m" |
| #define | COLOR_INFO "\x1b[32m" |
| #define | COLOR_WARN "\x1b[33m" |
| #define | COLOR_ERROR "\x1b[31m" |
| #define | COLOR_FATAL "\x1b[35m" |
| #define | COLOR_RESET "\x1b[0m" |
Functions | |
| static const char * | color_for_stream (b32 is_stderr, const char *color) |
| static void | lock (void) |
| Acquires the logger lock if a locking function is configured. | |
| static void | unlock (void) |
| Releases the logger lock if a locking function is configured. | |
| static void | log_stdout (BaseLogEvent *ev) |
| Formats and writes a log event to standard output or standard error. | |
| static void | file_callback (BaseLogEvent *ev, void *user_data) |
| Default callback used to write log events to a standard C FILE*. | |
| void | base_log_set_level (BaseLogLevel level) |
| Configures the active logging level. Messages below this level are ignored. | |
| void | base_log_set_quiet (b32 enable) |
| Mutes or unmutes all console (stdout/stderr) output. | |
| void | base_log_set_lock (BaseLogLockFn fn, void *user_data) |
| Configures thread-safety by providing a custom locking mechanism. | |
| b32 | base_log_add_fp (FILE *fp, BaseLogLevel min_level) |
| Adds a standard C FILE* pointer as a logging destination. | |
| b32 | base_log_add_callback (BaseLogFn fn, void *user_data, BaseLogLevel min_level) |
| Adds a custom callback function as a logging destination. | |
| b32 | base_log_remove_callback (BaseLogFn fn) |
| Removes a previously registered callback from the logger. | |
| void | base_log_message (BaseLogLevel level, const char *file, int line, const char *fmt,...) |
| Internal function that actually processes the log. DO NOT call directly. | |
Variables | |
| static BaseLogger | L = {.level = BASE_LOG_LEVEL_TRACE} |
| The single global logger instance state. | |
| static const char * | level_strings [] = {"TRACE", "DEBUG", "INFO", "WARN", "ERROR", "FATAL"} |
| Human-readable string representations of the log levels. | |
| static const char * | level_colors [] |
| Array mapping log levels to their respective ANSI color codes. | |
Implementation of the leveled logging subsystem.
Definition in file base_log.c.
| #define COLOR_DEBUG "\x1b[36m" |
Definition at line 39 of file base_log.c.
| #define COLOR_ERROR "\x1b[31m" |
Definition at line 42 of file base_log.c.
| #define COLOR_FATAL "\x1b[35m" |
Definition at line 43 of file base_log.c.
| #define COLOR_INFO "\x1b[32m" |
Definition at line 40 of file base_log.c.
| #define COLOR_RESET "\x1b[0m" |
Definition at line 44 of file base_log.c.
| #define COLOR_TRACE "\x1b[94m" |
Definition at line 38 of file base_log.c.
| #define COLOR_WARN "\x1b[33m" |
Definition at line 41 of file base_log.c.
| #define MAX_CALLBACKS 4 |
Maximum number of custom log callbacks supported simultaneously.
Definition at line 13 of file base_log.c.
|
static |
Definition at line 77 of file base_log.c.
|
static |
Default callback used to write log events to a standard C FILE*.
Definition at line 139 of file base_log.c.

|
static |
Acquires the logger lock if a locking function is configured.
Definition at line 92 of file base_log.c.

|
static |
Formats and writes a log event to standard output or standard error.
Definition at line 112 of file base_log.c.

|
static |
Releases the logger lock if a locking function is configured.
Definition at line 101 of file base_log.c.

|
static |
The single global logger instance state.
Definition at line 32 of file base_log.c.
|
static |
Array mapping log levels to their respective ANSI color codes.
Definition at line 85 of file base_log.c.
|
static |
Human-readable string representations of the log levels.
Definition at line 35 of file base_log.c.