Kohi Game Engine
logger.h
Go to the documentation of this file.
1 
12 #pragma once
13 
14 #include "defines.h"
15 
17 #define LOG_WARN_ENABLED 1
19 #define LOG_INFO_ENABLED 1
21 #define LOG_DEBUG_ENABLED 1
23 #define LOG_TRACE_ENABLED 1
24 
25 // Disable debug and trace logging for release builds.
26 #if KRELEASE == 1
27 #define LOG_DEBUG_ENABLED 0
28 #define LOG_TRACE_ENABLED 0
29 #endif
30 
32 typedef enum log_level {
44  LOG_LEVEL_TRACE = 5
46 
56 b8 logging_initialize(u64* memory_requirement, void* state, void* config);
57 
62 void logging_shutdown(void* state);
63 
70 KAPI void log_output(log_level level, const char* message, ...);
71 
77 #define KFATAL(message, ...) log_output(LOG_LEVEL_FATAL, message, ##__VA_ARGS__);
78 
79 #ifndef KERROR
86 #define KERROR(message, ...) log_output(LOG_LEVEL_ERROR, message, ##__VA_ARGS__);
87 #endif
88 
89 #if LOG_WARN_ENABLED == 1
96 #define KWARN(message, ...) log_output(LOG_LEVEL_WARN, message, ##__VA_ARGS__);
97 #else
104 #define KWARN(message, ...)
105 #endif
106 
107 #if LOG_INFO_ENABLED == 1
113 #define KINFO(message, ...) log_output(LOG_LEVEL_INFO, message, ##__VA_ARGS__);
114 #else
121 #define KINFO(message, ...)
122 #endif
123 
124 #if LOG_DEBUG_ENABLED == 1
130 #define KDEBUG(message, ...) log_output(LOG_LEVEL_DEBUG, message, ##__VA_ARGS__);
131 #else
138 #define KDEBUG(message, ...)
139 #endif
140 
141 #if LOG_TRACE_ENABLED == 1
147 #define KTRACE(message, ...) log_output(LOG_LEVEL_TRACE, message, ##__VA_ARGS__);
148 #else
155 #define KTRACE(message, ...)
156 #endif
This file contains global type definitions which are used throughout the entire engine and applicatio...
#define KAPI
Import/export qualifier.
Definition: defines.h:177
_Bool b8
8-bit boolean type
Definition: defines.h:58
unsigned long long u64
Unsigned 64-bit integer.
Definition: defines.h:28
KAPI void log_output(log_level level, const char *message,...)
Outputs logging at the given level.
log_level
Represents levels of logging.
Definition: logger.h:32
@ LOG_LEVEL_DEBUG
Debug log level, should be used for debugging purposes.
Definition: logger.h:42
@ LOG_LEVEL_ERROR
Error log level, should be used to indicate critical runtime problems that cause the application to r...
Definition: logger.h:36
@ LOG_LEVEL_FATAL
Fatal log level, should be used to stop the application when hit.
Definition: logger.h:34
@ LOG_LEVEL_TRACE
Trace log level, should be used for verbose debugging purposes.
Definition: logger.h:44
@ LOG_LEVEL_WARN
Warning log level, should be used to indicate non-critial problems with the application that cause it...
Definition: logger.h:38
@ LOG_LEVEL_INFO
Info log level, should be used for non-erronuous informational purposes.
Definition: logger.h:40
void logging_shutdown(void *state)
Shuts down the logging system.
b8 logging_initialize(u64 *memory_requirement, void *state, void *config)
Initializes logging system. Call twice; once with state = 0 to get required memory size,...