mirror of
https://github.com/tailix/kernel.git
synced 2024-12-11 11:35:39 -05:00
Improve logger
This commit is contained in:
parent
9912bcf2a1
commit
31d51bc38c
2 changed files with 28 additions and 13 deletions
|
@ -46,8 +46,7 @@ void exception_handler(struct IsrRegisters regs)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
logger_fail("Unhandled protected-mode exception:");
|
logger_fail("Unhandled protected-mode exception:\n%s", messages[regs.int_no]);
|
||||||
logger_fail(messages[regs.int_no]);
|
|
||||||
|
|
||||||
asm volatile("cli");
|
asm volatile("cli");
|
||||||
while (1) {}
|
while (1) {}
|
||||||
|
|
|
@ -18,22 +18,15 @@ static const char *const level_text[LEVELS_COUNT] = {
|
||||||
"FAIL",
|
"FAIL",
|
||||||
};
|
};
|
||||||
|
|
||||||
|
static void print_level(unsigned char level);
|
||||||
|
|
||||||
void logger_log(unsigned char level, const char *format, ...)
|
void logger_log(unsigned char level, const char *format, ...)
|
||||||
{
|
{
|
||||||
if (level >= LEVELS_COUNT) {
|
if (level >= LEVELS_COUNT) {
|
||||||
level = LEVELS_COUNT - 1;
|
level = LEVELS_COUNT - 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
console_setcolor(VGA_COLOR_LIGHT_GREY);
|
print_level(level);
|
||||||
console_putc('[');
|
|
||||||
|
|
||||||
console_setcolor(level_colors[level]);
|
|
||||||
console_print(level_text[level]);
|
|
||||||
|
|
||||||
console_setcolor(VGA_COLOR_LIGHT_GREY);
|
|
||||||
console_putc(']');
|
|
||||||
|
|
||||||
console_putc(' ');
|
|
||||||
|
|
||||||
console_setcolor(VGA_COLOR_WHITE);
|
console_setcolor(VGA_COLOR_WHITE);
|
||||||
|
|
||||||
|
@ -42,9 +35,18 @@ void logger_log(unsigned char level, const char *format, ...)
|
||||||
char buf[20];
|
char buf[20];
|
||||||
arg++;
|
arg++;
|
||||||
|
|
||||||
|
unsigned char color = VGA_COLOR_WHITE;
|
||||||
|
|
||||||
while ((c = *format++) != 0)
|
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);
|
console_putc(c);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
@ -90,3 +92,17 @@ string:
|
||||||
|
|
||||||
console_putc('\n');
|
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(' ');
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in a new issue