1
0
Fork 0
mirror of https://github.com/tailix/kernel.git synced 2024-10-30 12:03:52 -04:00

Improve logger

This commit is contained in:
Braiden Vasco 2017-11-06 04:01:49 +00:00
parent 9912bcf2a1
commit 31d51bc38c
2 changed files with 28 additions and 13 deletions

View file

@ -46,8 +46,7 @@ void exception_handler(struct IsrRegisters regs)
return;
}
logger_fail("Unhandled protected-mode exception:");
logger_fail(messages[regs.int_no]);
logger_fail("Unhandled protected-mode exception:\n%s", messages[regs.int_no]);
asm volatile("cli");
while (1) {}

View file

@ -18,22 +18,15 @@ static const char *const level_text[LEVELS_COUNT] = {
"FAIL",
};
static void print_level(unsigned char level);
void logger_log(unsigned char level, const char *format, ...)
{
if (level >= LEVELS_COUNT) {
level = LEVELS_COUNT - 1;
}
console_setcolor(VGA_COLOR_LIGHT_GREY);
console_putc('[');
console_setcolor(level_colors[level]);
console_print(level_text[level]);
console_setcolor(VGA_COLOR_LIGHT_GREY);
console_putc(']');
console_putc(' ');
print_level(level);
console_setcolor(VGA_COLOR_WHITE);
@ -42,9 +35,18 @@ void logger_log(unsigned char level, const char *format, ...)
char buf[20];
arg++;
unsigned char color = VGA_COLOR_WHITE;
while ((c = *format++) != 0)
{
if (c != '%') {
console_setcolor(color);
if (c == '\n') {
console_putc('\n');
print_level(level);
color = VGA_COLOR_LIGHT_GREY;
}
else if (c != '%') {
console_putc(c);
}
else {
@ -90,3 +92,17 @@ string:
console_putc('\n');
}
void print_level(unsigned char level)
{
console_setcolor(VGA_COLOR_LIGHT_GREY);
console_putc('[');
console_setcolor(level_colors[level]);
console_print(level_text[level]);
console_setcolor(VGA_COLOR_LIGHT_GREY);
console_putc(']');
console_putc(' ');
}