feat(util): Add log function for logging in exception handlers

We want this to always be visible, so the log level must be
the highest possible. Unfortunately, that's quite the hack
around the existing API and how fatal behaves.

The log API stopped scaling already a while ago and needs
considerable refactoring to consider the various use-cases
that emerged since it was first created on alpha versions
of bemanitools.
This commit is contained in:
icex2
2024-01-31 21:21:00 +01:00
parent bdf493d2fb
commit 69e469858c
2 changed files with 10 additions and 0 deletions
+9
View File
@@ -64,6 +64,15 @@ static void log_builtin_format(
}
}
void log_exception_handler(const char *fmt, ...)
{
va_list ap;
va_start(ap, fmt);
log_builtin_format(LOG_LEVEL_FATAL, LOG_MODULE, fmt, ap);
va_end(ap);
}
void log_assert_body(const char *file, int line, const char *function)
{
log_impl_fatal("assert", "%s:%d: function `%s'", file, line, function);
+1
View File
@@ -66,6 +66,7 @@ enum log_level {
LOG_LEVEL_MISC = 3,
};
void log_exception_handler(const char *fmt, ...);
void log_assert_body(const char *file, int line, const char *function);
void log_to_external(
log_formatter_t misc,