Remove unnecessary error propagation in Log.cpp
All checks were successful
continuous-integration/drone/push Build is passing
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:
parent
314acbfe21
commit
c099877c35
@ -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 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 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_list ap;
|
||||||
va_copy(ap, origin);
|
va_copy(ap, origin);
|
||||||
|
|
||||||
TRY(Serial::printf("\x1b[%sm%c\x1b[0m ", ansi_color_codes_per_log_level[(int)level],
|
Serial::printf("\x1b[%sm%c\x1b[0m ", ansi_color_codes_per_log_level[(int)level], log_level_letters[(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,
|
format,
|
||||||
[](char c, void*) -> Result<void> {
|
[](char c, void*) -> Result<void> {
|
||||||
Serial::putchar(c);
|
Serial::putchar(c);
|
||||||
return {};
|
return {};
|
||||||
},
|
},
|
||||||
nullptr, ap));
|
nullptr, ap);
|
||||||
|
|
||||||
Serial::putchar('\n');
|
Serial::putchar('\n');
|
||||||
|
|
||||||
va_end(ap);
|
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_list ap;
|
||||||
va_copy(ap, origin);
|
va_copy(ap, origin);
|
||||||
@ -58,13 +55,13 @@ static Result<void> log_text_console(LogLevel level, const char* format, va_list
|
|||||||
else
|
else
|
||||||
TextConsole::set_foreground(WHITE);
|
TextConsole::set_foreground(WHITE);
|
||||||
|
|
||||||
TRY(cstyle_format(
|
cstyle_format(
|
||||||
format,
|
format,
|
||||||
[](char c, void*) -> Result<void> {
|
[](char c, void*) -> Result<void> {
|
||||||
TextConsole::putchar(c);
|
TextConsole::putchar(c);
|
||||||
return {};
|
return {};
|
||||||
},
|
},
|
||||||
nullptr, ap));
|
nullptr, ap);
|
||||||
|
|
||||||
TextConsole::putchar('\n');
|
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);
|
TextConsole::set_foreground(original_foreground);
|
||||||
|
|
||||||
va_end(ap);
|
va_end(ap);
|
||||||
|
|
||||||
return {};
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Result<void> vlog(LogLevel level, const char* format, va_list ap)
|
Result<void> vlog(LogLevel level, const char* format, va_list ap)
|
||||||
{
|
{
|
||||||
if (!g_debug_enabled && level == LogLevel::Debug) return {};
|
if (!g_debug_enabled && level == LogLevel::Debug) return {};
|
||||||
|
|
||||||
if (g_serial_enabled) TRY(log_serial(level, format, ap));
|
if (g_serial_enabled) log_serial(level, format, ap);
|
||||||
if (g_text_console_enabled) TRY(log_text_console(level, format, ap));
|
if (g_text_console_enabled) log_text_console(level, format, ap);
|
||||||
|
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user