Compare commits

...

2 Commits

3 changed files with 13 additions and 2 deletions

View File

@ -14,11 +14,17 @@ static constexpr u32 WHITE = 0xffffffff;
static constexpr u32 YELLOW = 0xffffff00;
static constexpr u32 RED = 0xffff0000;
static Result<void> log_serial(LogLevel, const char* format, va_list origin)
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)
{
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]));
TRY(Serial::printf("[%6zu.%.6zu] ", Timer::ticks(), Timer::ticks_us() - (Timer::ticks() * 1000000)));
TRY(cstyle_format(

View File

@ -1,4 +1,5 @@
#pragma once
#include <Attributes.h>
#include <Result.h>
#include <stdarg.h>
@ -11,7 +12,7 @@ enum class LogLevel
};
Result<void> vlog(LogLevel level, const char* format, va_list ap);
Result<void> log(LogLevel level, const char* format, ...);
Result<void> log(LogLevel level, const char* format, ...) _format(2, 3);
void setup_log(bool enable_debug, bool enable_serial, bool enable_text_console);
bool log_debug_enabled();

View File

@ -33,6 +33,10 @@ Result<void> init()
to_dynamic_unit(MemoryManager::reserved(), buffer, sizeof(buffer));
kinfoln("Reserved memory: %s", buffer);
volatile char* p = (volatile char*)0xefe0f3445692d;
*p = 7;
return {};
}