CBuild wiki
This file provides small logger utility.
License: GPL-3.0-or-later.
typedef enum {
CBUILD_LOG_ERROR = 1,
CBUILD_LOG_WARN = 2,
CBUILD_LOG_INFO = 3,
CBUILD_LOG_TRACE = 4,
} cbuild_log_level_t;Supported log levels. Compared arithmetically.
This can be overridden by defining
CBUILD_LOG_CUSTOM_LEVELS and then providing enumeration
cbuild_custom_log_level_t (without typedef). This 4 levels
should be present in you implementation of this enum, because they are
used by CBuild itself.
You would also need to provide
const char* __cbuild_log_level_names[]. This array is used
by default handler to format names of log levels. Level is used as index
and value is treated as a c-string.
Main dispatcher for logger. Support printf-style formatting.
cbuild_log_level_t level Log level. Will be used both for
printing and for disabling logs based on minimum level.const char*
fmt Format string for printf.variadics … Arguments for format string.Wrapper for cbuild_log
that sets level to CBUILD_LOG_ERROR.
Wrapper for cbuild_log
that sets level to CBUILD_LOG_WARN.
Wrapper for cbuild_log
that sets level to CBUILD_LOG_INFO.
Wrapper for cbuild_log
that sets level to CBUILD_LOG_TRACE.
Same as cbuild_log
but takes va_list instead of
variadics.
cbuild_log_level_t level Log level. Will be used both for
printing and for disabling logs based on minimum level.const char*
fmt Format string for printf.va_list args Arguments for format string.Set minimum level of logs that will be printed.
Name of this functions is rather misleading, because it disable all levels that are arithmetically higher than specified here. So technically it set maximum level. But for logs levels lower technically means less severe, so name is like this.
Get minimum level of logs that would be printed.
This function will be called only for messages that should be printed. It can be treated as a formatter for logged messages.
const char*
level Log level name.const char*
fmt Format string for printf.va_list args Arguments for format string.Setup handler for logger. Passing NULL will disable logs. Default log handler will be setup by default.
Get current log handler.
Default log handler for CBuild.