Add temporary log output

Currently the kernel idle process is an infinite loop printing logs,
with no locking.
This commit is contained in:
Justin C. Miller
2019-03-19 00:51:33 -07:00
parent 39524b2b9f
commit 7fe1b7d1f5
5 changed files with 73 additions and 15 deletions

View File

@@ -1,5 +1,6 @@
#include "kutil/constexpr_hash.h"
#include "kutil/memory.h"
#include "console.h"
#include "log.h"
namespace logs {
@@ -13,6 +14,33 @@ static log::logger g_logger(log_buffer, sizeof(log_buffer));
#include "log_areas.inc"
#undef LOG
static const uint8_t level_colors[] = {0x07, 0x07, 0x0f, 0x0b, 0x09};
static void
output_log(log::level severity, log::area_t area, const char *message)
{
}
void
output_logs()
{
uint8_t buffer[257];
auto *ent = reinterpret_cast<log::logger::entry *>(buffer);
auto *cons = console::get();
while (true) {
if(g_logger.get_entry(buffer, sizeof(buffer))) {
buffer[ent->bytes] = 0;
cons->set_color(level_colors[static_cast<int>(ent->severity)]);
cons->printf("%9s %8s: %s\n",
g_logger.area_name(ent->area),
g_logger.level_name(ent->severity),
ent->message);
cons->set_color();
}
}
}
void init()
{
new (&g_logger) log::logger(log_buffer, sizeof(log_buffer));