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

Go to the source code of this file.
Classes | |
| struct | Callback |
| Internal structure to hold a logging callback and its configuration. More... | |
| struct | Logger |
| 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" |
| ANSI Light Blue for TRACE. | |
| #define | COLOR_DEBUG "\x1b[36m" |
| ANSI Cyan for DEBUG. | |
| #define | COLOR_INFO "\x1b[32m" |
| ANSI Green for INFO. | |
| #define | COLOR_WARN "\x1b[33m" |
| ANSI Yellow for WARN. | |
| #define | COLOR_ERROR "\x1b[31m" |
| ANSI Red for ERROR. | |
| #define | COLOR_FATAL "\x1b[35m" |
| ANSI Magenta for FATAL. | |
| #define | COLOR_RESET "\x1b[0m" |
| ANSI color reset sequence. | |
Typedefs | |
| typedef struct Callback | Callback |
| Internal structure to hold a logging callback and its configuration. | |
| typedef struct Logger | Logger |
| Internal state structure for the global logger. | |
Functions | |
| 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 (LogEvent *ev) |
| Formats and writes a log event to standard output or standard error. | |
| static void | file_callback (LogEvent *ev, void *user_data) |
| Default callback used to write log events to a standard C FILE*. | |
| void | log_set_level (LogLevel level) |
| Configures the active logging level. Messages below this level are ignored. | |
| void | log_set_quiet (b32 enable) |
| Mutes or unmutes all console (stdout/stderr) output. | |
| void | log_set_lock (LogLockFn fn, void *user_data) |
| Configures thread-safety by providing a custom locking mechanism. | |
| b32 | log_add_fp (FILE *fp, LogLevel min_level) |
| Adds a standard C FILE* pointer as a logging destination. | |
| b32 | log_add_callback (LogFn fn, void *user_data, LogLevel min_level) |
| Adds a custom callback function as a logging destination. | |
| void | log_message (LogLevel level, const char *file, int line, const char *fmt,...) |
| Internal function that actually processes the log. DO NOT call directly. | |
Variables | |
| static Logger | L = {.level = 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" |
ANSI Cyan for DEBUG.
Definition at line 57 of file base_log.c.
| #define COLOR_ERROR "\x1b[31m" |
ANSI Red for ERROR.
Definition at line 63 of file base_log.c.
| #define COLOR_FATAL "\x1b[35m" |
ANSI Magenta for FATAL.
Definition at line 65 of file base_log.c.
| #define COLOR_INFO "\x1b[32m" |
ANSI Green for INFO.
Definition at line 59 of file base_log.c.
| #define COLOR_RESET "\x1b[0m" |
ANSI color reset sequence.
Definition at line 67 of file base_log.c.
| #define COLOR_TRACE "\x1b[94m" |
ANSI Light Blue for TRACE.
Definition at line 55 of file base_log.c.
| #define COLOR_WARN "\x1b[33m" |
ANSI Yellow for WARN.
Definition at line 61 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 |
Default callback used to write log events to a standard C FILE*.
| ev | The log event to process. |
| user_data | An active FILE* pointer cast to void*. |
Definition at line 127 of file base_log.c.

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

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

|
static |
Releases the logger lock if a locking function is configured.
Definition at line 87 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 71 of file base_log.c.
|
static |
Human-readable string representations of the log levels.
Definition at line 35 of file base_log.c.