cbase 1.46.11
C/C++ Static Template
Loading...
Searching...
No Matches
Logging Subsystem

Classes

struct  LogEvent
 A structured event containing all metadata for a single log message. More...

Typedefs

typedef enum LogLevel LogLevel
 The severity level of a log message.
typedef struct LogEvent LogEvent
 A structured event containing all metadata for a single log message.
typedef void(* LogFn) (LogEvent *ev, void *user_data)
 Signature for custom logging destination callbacks.
typedef void(* LogLockFn) (void *user_data, b32 lock)
 Signature for the thread-synchronization callback.

Enumerations

enum  LogLevel {
  LOG_LEVEL_TRACE , LOG_LEVEL_DEBUG , LOG_LEVEL_INFO , LOG_LEVEL_WARN ,
  LOG_LEVEL_ERROR , LOG_LEVEL_FATAL , LOG_LEVEL_COUNT
}
 The severity level of a log message. More...

Functions

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.

Detailed Description

Typedef Documentation

◆ LogFn

typedef void(* LogFn) (LogEvent *ev, void *user_data)

Signature for custom logging destination callbacks.

Definition at line 62 of file base_log.h.

◆ LogLockFn

typedef void(* LogLockFn) (void *user_data, b32 lock)

Signature for the thread-synchronization callback.

Definition at line 65 of file base_log.h.

Enumeration Type Documentation

◆ LogLevel

enum LogLevel

The severity level of a log message.

Enumerator
LOG_LEVEL_TRACE 

Fine-grained, step-by-step debug information.

LOG_LEVEL_DEBUG 

Diagnostic information useful for developers.

LOG_LEVEL_INFO 

General application flow events.

LOG_LEVEL_WARN 

Abnormal but non-fatal events.

LOG_LEVEL_ERROR 

Recoverable errors that impact a specific operation.

LOG_LEVEL_FATAL 

Critical errors causing an application crash or shutdown.

Definition at line 42 of file base_log.h.

Function Documentation

◆ log_add_callback()

b32 log_add_callback ( LogFn fn,
void * user_data,
LogLevel min_level )

Adds a custom callback function as a logging destination.

Parameters
fnThe function pointer to invoke for every log event.
user_dataOpaque pointer passed to the callback.
min_levelThe minimum severity level to send to this callback.

Definition at line 166 of file base_log.c.

Here is the caller graph for this function:

◆ log_add_fp()

b32 log_add_fp ( FILE * fp,
LogLevel min_level )

Adds a standard C FILE* pointer as a logging destination.

Parameters
fpThe file pointer (must be opened in "a" or "w" mode).
min_levelThe minimum severity level to write to this file.

Definition at line 160 of file base_log.c.

Here is the call graph for this function:

◆ log_message()

void log_message ( LogLevel level,
const char * file,
int line,
const char * fmt,
... )

Internal function that actually processes the log. DO NOT call directly.

Note
Use the LOG_* macros instead.

Definition at line 180 of file base_log.c.

Here is the call graph for this function:

◆ log_set_level()

void log_set_level ( LogLevel level)

Configures the active logging level. Messages below this level are ignored.

Parameters
levelThe minimum level to output (e.g., LOG_LEVEL_INFO).

Definition at line 141 of file base_log.c.

◆ log_set_lock()

void log_set_lock ( LogLockFn fn,
void * user_data )

Configures thread-safety by providing a custom locking mechanism.

Parameters
fnThe callback to invoke when a lock/unlock is required.
user_dataOpaque pointer passed to the locking callback (e.g., a Mutex).

Definition at line 153 of file base_log.c.

◆ log_set_quiet()

void log_set_quiet ( b32 enable)

Mutes or unmutes all console (stdout/stderr) output.

Parameters
enable1 (true) to mute console output, 0 (false) to enable it.

Definition at line 147 of file base_log.c.