Kohi Game Engine
logger.h File Reference

This file contains structures and logic pertaining to the logging system. More...

#include "defines.h"

Go to the source code of this file.

Macros

#define LOG_WARN_ENABLED   1
 Indicates if warning level logging is enabled. More...
 
#define LOG_INFO_ENABLED   1
 Indicates if info level logging is enabled. More...
 
#define LOG_DEBUG_ENABLED   1
 Indicates if debug level logging is enabled. More...
 
#define LOG_TRACE_ENABLED   1
 Indicates if trace level logging is enabled. More...
 
#define KFATAL(message, ...)   log_output(LOG_LEVEL_FATAL, message, ##__VA_ARGS__);
 Logs a fatal-level message. Should be used to stop the application when hit. More...
 
#define KERROR(message, ...)   log_output(LOG_LEVEL_ERROR, message, ##__VA_ARGS__);
 Logs an error-level message. Should be used to indicate critical runtime problems that cause the application to run improperly or not at all. More...
 
#define KWARN(message, ...)   log_output(LOG_LEVEL_WARN, message, ##__VA_ARGS__);
 Logs a warning-level message. Should be used to indicate non-critial problems with the application that cause it to run suboptimally. More...
 
#define KINFO(message, ...)   log_output(LOG_LEVEL_INFO, message, ##__VA_ARGS__);
 Logs an info-level message. Should be used for non-erronuous informational purposes. More...
 
#define KDEBUG(message, ...)   log_output(LOG_LEVEL_DEBUG, message, ##__VA_ARGS__);
 Logs a debug-level message. Should be used for debugging purposes. More...
 
#define KTRACE(message, ...)   log_output(LOG_LEVEL_TRACE, message, ##__VA_ARGS__);
 Logs a trace-level message. Should be used for verbose debugging purposes. More...
 

Typedefs

typedef enum log_level log_level
 Represents levels of logging. More...
 

Enumerations

enum  log_level {
  LOG_LEVEL_FATAL = 0 , LOG_LEVEL_ERROR = 1 , LOG_LEVEL_WARN = 2 , LOG_LEVEL_INFO = 3 ,
  LOG_LEVEL_DEBUG = 4 , LOG_LEVEL_TRACE = 5
}
 Represents levels of logging. More...
 

Functions

b8 logging_initialize (u64 *memory_requirement, void *state, void *config)
 Initializes logging system. Call twice; once with state = 0 to get required memory size, then a second time passing allocated memory to state. More...
 
void logging_shutdown (void *state)
 Shuts down the logging system. More...
 
KAPI void log_output (log_level level, const char *message,...)
 Outputs logging at the given level. More...
 

Detailed Description

This file contains structures and logic pertaining to the logging system.

Author
Travis Vroman (travi.nosp@m.s@ko.nosp@m.hieng.nosp@m.ine..nosp@m.com)
Version
1.0
Date
2022-01-10

Macro Definition Documentation

◆ KDEBUG

#define KDEBUG (   message,
  ... 
)    log_output(LOG_LEVEL_DEBUG, message, ##__VA_ARGS__);

Logs a debug-level message. Should be used for debugging purposes.

Parameters
messageThe message to be logged.
...Any formatted data that should be included in the log entry.

◆ KERROR

#define KERROR (   message,
  ... 
)    log_output(LOG_LEVEL_ERROR, message, ##__VA_ARGS__);

Logs an error-level message. Should be used to indicate critical runtime problems that cause the application to run improperly or not at all.

Parameters
messageThe message to be logged.
...Any formatted data that should be included in the log entry.

◆ KFATAL

#define KFATAL (   message,
  ... 
)    log_output(LOG_LEVEL_FATAL, message, ##__VA_ARGS__);

Logs a fatal-level message. Should be used to stop the application when hit.

Parameters
messageThe message to be logged. Can be a format string for additional parameters.
...Additional parameters to be logged.

◆ KINFO

#define KINFO (   message,
  ... 
)    log_output(LOG_LEVEL_INFO, message, ##__VA_ARGS__);

Logs an info-level message. Should be used for non-erronuous informational purposes.

Parameters
messageThe message to be logged.
...Any formatted data that should be included in the log entry.

◆ KTRACE

#define KTRACE (   message,
  ... 
)    log_output(LOG_LEVEL_TRACE, message, ##__VA_ARGS__);

Logs a trace-level message. Should be used for verbose debugging purposes.

Parameters
messageThe message to be logged.
...Any formatted data that should be included in the log entry.

◆ KWARN

#define KWARN (   message,
  ... 
)    log_output(LOG_LEVEL_WARN, message, ##__VA_ARGS__);

Logs a warning-level message. Should be used to indicate non-critial problems with the application that cause it to run suboptimally.

Parameters
messageThe message to be logged.
...Any formatted data that should be included in the log entry.

◆ LOG_DEBUG_ENABLED

#define LOG_DEBUG_ENABLED   1

Indicates if debug level logging is enabled.

◆ LOG_INFO_ENABLED

#define LOG_INFO_ENABLED   1

Indicates if info level logging is enabled.

◆ LOG_TRACE_ENABLED

#define LOG_TRACE_ENABLED   1

Indicates if trace level logging is enabled.

◆ LOG_WARN_ENABLED

#define LOG_WARN_ENABLED   1

Indicates if warning level logging is enabled.

Typedef Documentation

◆ log_level

typedef enum log_level log_level

Represents levels of logging.

Enumeration Type Documentation

◆ log_level

enum log_level

Represents levels of logging.

Enumerator
LOG_LEVEL_FATAL 

Fatal log level, should be used to stop the application when hit.

LOG_LEVEL_ERROR 

Error log level, should be used to indicate critical runtime problems that cause the application to run improperly or not at all.

LOG_LEVEL_WARN 

Warning log level, should be used to indicate non-critial problems with the application that cause it to run suboptimally.

LOG_LEVEL_INFO 

Info log level, should be used for non-erronuous informational purposes.

LOG_LEVEL_DEBUG 

Debug log level, should be used for debugging purposes.

LOG_LEVEL_TRACE 

Trace log level, should be used for verbose debugging purposes.

Function Documentation

◆ log_output()

KAPI void log_output ( log_level  level,
const char *  message,
  ... 
)

Outputs logging at the given level.

Parameters
levelThe log level to use.
messageThe message to be logged.
...Any formatted data that should be included in the log entry.

◆ logging_initialize()

b8 logging_initialize ( u64 memory_requirement,
void *  state,
void *  config 
)

Initializes logging system. Call twice; once with state = 0 to get required memory size, then a second time passing allocated memory to state.

Parameters
memory_requirementA pointer to hold the required memory size of internal state.
state0 if just requesting memory requirement, otherwise allocated block of memory.
configIgnored.
Returns
b8 True on success; otherwise false.

◆ logging_shutdown()

void logging_shutdown ( void *  state)

Shuts down the logging system.

Parameters
stateA pointer to the system state.