Remove unnecessary error propagation in Log.cpp
All checks were successful
continuous-integration/drone/push Build is passing

Serial and TextConsole always succeed, no need to act as if they could fail
This commit is contained in:
apio 2022-12-06 19:35:34 +01:00
parent 314acbfe21
commit c099877c35
Signed by: apio
GPG Key ID: B8A7D06E42258954

View File

@ -17,32 +17,29 @@ static constexpr u32 RED = 0xffff0000;
static char log_level_letters[] = {'D', 'I', 'W', 'E'}; // D for debug, I for info, W for warning, E for error
static const char* ansi_color_codes_per_log_level[] = {"37", "37", "33", "31"}; // 37 is white, 33 yellow, 31 red
static Result<void> log_serial(LogLevel level, const char* format, va_list origin)
static void log_serial(LogLevel level, const char* format, va_list origin)
{
va_list ap;
va_copy(ap, origin);
TRY(Serial::printf("\x1b[%sm%c\x1b[0m ", ansi_color_codes_per_log_level[(int)level],
log_level_letters[(int)level]));
Serial::printf("\x1b[%sm%c\x1b[0m ", ansi_color_codes_per_log_level[(int)level], log_level_letters[(int)level]);
TRY(Serial::printf("%4zu.%.3zu ", Timer::ticks(), Timer::ticks_ms() - (Timer::ticks() * 1000)));
Serial::printf("%4zu.%.3zu ", Timer::ticks(), Timer::ticks_ms() - (Timer::ticks() * 1000));
TRY(cstyle_format(
cstyle_format(
format,
[](char c, void*) -> Result<void> {
Serial::putchar(c);
return {};
},
nullptr, ap));
nullptr, ap);
Serial::putchar('\n');
va_end(ap);
return {};
}
static Result<void> log_text_console(LogLevel level, const char* format, va_list origin)
static void log_text_console(LogLevel level, const char* format, va_list origin)
{
va_list ap;
va_copy(ap, origin);
@ -58,13 +55,13 @@ static Result<void> log_text_console(LogLevel level, const char* format, va_list
else
TextConsole::set_foreground(WHITE);
TRY(cstyle_format(
cstyle_format(
format,
[](char c, void*) -> Result<void> {
TextConsole::putchar(c);
return {};
},
nullptr, ap));
nullptr, ap);
TextConsole::putchar('\n');
@ -73,16 +70,14 @@ static Result<void> log_text_console(LogLevel level, const char* format, va_list
TextConsole::set_foreground(original_foreground);
va_end(ap);
return {};
}
Result<void> vlog(LogLevel level, const char* format, va_list ap)
{
if (!g_debug_enabled && level == LogLevel::Debug) return {};
if (g_serial_enabled) TRY(log_serial(level, format, ap));
if (g_text_console_enabled) TRY(log_text_console(level, format, ap));
if (g_serial_enabled) log_serial(level, format, ap);
if (g_text_console_enabled) log_text_console(level, format, ap);
return {};
}