9 #include <kiba/format/format.h>
13 static const char *level_names[LOG_LEVEL_MAX] = {
22 static log_level stacktrace_level = LOG_LEVEL_MAX;
23 static log_level active_log_level = LOG_LEVEL_TRACE;
32 if (active_log_level != LOG_LEVEL_MAX && level <= active_log_level) {
33 char log_message[KB_MAX_LOG_ENTRY_SIZE] = {0};
37 if (format_buffer_create_static(&buf, FORMAT_BUFFER_WRITE, log_message, KB_MAX_LOG_ENTRY_SIZE)
38 && format(&buf,
"{raw_string} {raw_string}:{i64} ", level_names[level], file, line)
39 && format_va_list(&buf, msg, &args) && format_buffer_add_char(&buf,
'\n')) {
41 if (stacktrace_level != LOG_LEVEL_MAX && level <= stacktrace_level) {
50 if (level < LOG_LEVEL_WARN) {
Interface to access platform specific console printing functionality.
void platform_print_stacktrace(void)
Print the the call stack of the caller.
void platform_console_write(const char *msg, u8 color)
Write message to the platforms console.
void platform_console_write_error(const char *msg, u8 color)
Write message to the platforms error console.
Lightweight layer between platform and other engine components to enable tracing/monitoring.
void disable_stacktraces(void)
Disables output of the stacktrace.
void log_set_active_level(log_level level)
Set the minimum log level to log.
void enable_stacktraces(log_level level)
Enables output of the stacktrace.
void write_log_entry(log_level level, const char *file, long int line, const char *msg,...)
Create log entry and write to output channel.
void write_to_console(log_level level, const char *msg)
Write string to console.
log_level
Available log levels.