Logging#
Optional logging facility compatible with the ABR SDK logging callbacks.
These logging functions are used by the example programs, but may also be included in user-programs. The logging facilities may be disabled by setting the ABR_SDK_LOG_ENABLED macro to zero.
- Author
Andreas Stöckel (Applied Brain Research)
Typedefs
Functions
-
void abr_log_init(abr_log_t *log)#
Initializes the provided abr_log_t structure.
This automatically detects whether color should be used or not. Color is disabled when not writing to a TTY and depending on the NO_COLOR environment variable.
Directly write to the struct member after initialization to change options or to connect a write callback that does not write to stdout.
- Parameters:
log – Logger to initialize.
-
void abr_log(abr_log_t *log, abr_log_level_t level, const char *format, ...)#
Logs a log message to the
abr_log_tinstance.Note that this function is part of the optional logging framework. The logging framework may be completely disabled by defining the ABR_SDK_LOG_ENABLED as
0.The maximum length of the messages that can be logged is limited by
ABR_SDK_LOG_BUFFER_SIZE, which defaults to 1024.- Parameters:
log – Logger to which the log message should be sent. If
NULLis passed, this function logs using a temporary logger initialized with default settings.level – Severity of the log message.
format – Standard
printf-style format string that should be used for logging.... – Arguments that should be interpolated into the format string.
-
void abr_log_cb(void *user_data, abr_log_level_t level, const char *msg)#
Logging function compatible with the abr_log_cb_t callback function type.
- Parameters:
user_data – May be
NULLor a reference at a abr_log_t instance to customize logging.level – Severity of the message being logged.
msg – Message that should be logged.
-
struct abr_log
State of the optional logging module provided by the ABR SDK.
Use abr_log_init() to initialize this struct.
Public Members
-
abr_log_cb_t log_cb#
Write callback that is used whenever we log to this log instance.
-
void *log_cb_user_data#
User data that is passed as a first argument to the write callback.
-
bool use_color#
Whether ANSI escape codes/Windows terminal control commands should be used to create a colorful log.
-
abr_log_level_t min_level#
Minimum log level to use.
-
abr_log_cb_t log_cb#