$darkmode
Suckless OGL 1.0.0
A lean, high-performance C11 PBR Renderer
log.h File Reference

Thread-safe logging utility with timestamps and severity levels. More...

This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define LOG_DEBUG(tag, ...)   log_message(LOG_LEVEL_DEBUG, tag, __VA_ARGS__)
 Log a debug message. More...
 
#define LOG_INFO(tag, ...)   log_message(LOG_LEVEL_INFO, tag, __VA_ARGS__)
 Log an info message. More...
 
#define LOG_WARNING(tag, ...)   log_message(LOG_LEVEL_WARNING, tag, __VA_ARGS__)
 Log a warning message. More...
 
#define LOG_WARN(tag, ...)   LOG_WARNING(tag, __VA_ARGS__)
 Alias for LOG_WARNING. More...
 
#define LOG_ERROR(tag, ...)   log_message(LOG_LEVEL_ERROR, tag, __VA_ARGS__)
 Log an error message. More...
 
#define LOG_CRITICAL(tag, ...)   log_message(LOG_LEVEL_CRITICAL, tag, __VA_ARGS__)
 Log a critical failure message. More...
 

Typedefs

typedef void(* LogCallback) (LogLevel level, const char *tag, const char *message)
 Callback type for log message interception. More...
 

Enumerations

enum  LogLevel {
  LOG_LEVEL_NOTSET = 0 , LOG_LEVEL_DEBUG = 10 , LOG_LEVEL_INFO , LOG_LEVEL_WARNING = 30 ,
  LOG_LEVEL_ERROR = 40 , LOG_LEVEL_CRITICAL = 50
}
 Severity levels for log filtering. More...
 

Functions

void log_message (LogLevel level, const char *tag, const char *format,...)
 Logs a formatted message. More...
 
void log_set_callback (LogCallback callback)
 Sets a custom callback for log messages. More...
 
void log_set_level (LogLevel level)
 Sets the global minimum log level. More...
 
LogLevel log_get_level (void)
 Retrieves the current global log level. More...
 

Detailed Description

Thread-safe logging utility with timestamps and severity levels.

Macro Definition Documentation

◆ LOG_CRITICAL

#define LOG_CRITICAL (   tag,
  ... 
)    log_message(LOG_LEVEL_CRITICAL, tag, __VA_ARGS__)

Log a critical failure message.

◆ LOG_DEBUG

#define LOG_DEBUG (   tag,
  ... 
)    log_message(LOG_LEVEL_DEBUG, tag, __VA_ARGS__)

Log a debug message.

◆ LOG_ERROR

#define LOG_ERROR (   tag,
  ... 
)    log_message(LOG_LEVEL_ERROR, tag, __VA_ARGS__)

Log an error message.

◆ LOG_INFO

#define LOG_INFO (   tag,
  ... 
)    log_message(LOG_LEVEL_INFO, tag, __VA_ARGS__)

Log an info message.

◆ LOG_WARN

#define LOG_WARN (   tag,
  ... 
)    LOG_WARNING(tag, __VA_ARGS__)

Alias for LOG_WARNING.

◆ LOG_WARNING

#define LOG_WARNING (   tag,
  ... 
)    log_message(LOG_LEVEL_WARNING, tag, __VA_ARGS__)

Log a warning message.

Typedef Documentation

◆ LogCallback

typedef void(* LogCallback) (LogLevel level, const char *tag, const char *message)

Callback type for log message interception.

Parameters
levelSensitivity level.
tagCategory label.
messageThe full formatted log message.

Enumeration Type Documentation

◆ LogLevel

enum LogLevel

Severity levels for log filtering.

Enumerator
LOG_LEVEL_NOTSET 

Undefined level.

LOG_LEVEL_DEBUG 

Fine-grained informational events that are most useful to debug an application.

LOG_LEVEL_INFO 

Informational messages that highlight the progress of the application at coarse-grained level.

LOG_LEVEL_WARNING 

Potentially harmful situations.

LOG_LEVEL_ERROR 

Error events that might still allow the application to continue running.

LOG_LEVEL_CRITICAL 

Very severe error events that will presumably lead the application to abort.

Function Documentation

◆ log_get_level()

LogLevel log_get_level ( void  )

Retrieves the current global log level.

Returns
Active LogLevel.
Here is the call graph for this function:

◆ log_message()

void log_message ( LogLevel  level,
const char *  tag,
const char *  format,
  ... 
)

Logs a formatted message.

Format: YYYY-MM-DD HH:MM:SS,mmm - tag - LEVEL - message

Parameters
levelSeverity level.
tagCategory label (e.g., "RENDER", "INPUT").
formatPrintf-style format string.
...Arguments for the format string.
Here is the call graph for this function:

◆ log_set_callback()

void log_set_callback ( LogCallback  callback)

Sets a custom callback for log messages.

Parameters
callbackFunction to call for each log message, or NULL to disable.

◆ log_set_level()

void log_set_level ( LogLevel  level)

Sets the global minimum log level.

Parameters
levelLevels below this will be ignored.