feature: log level on kprintf (color)
fix: kprintf now uses concatenated strings for the flag
This commit is contained in:
@ -1,11 +1,15 @@
|
||||
#include "ctype.h"
|
||||
#include "kprintf.h"
|
||||
#include "stdlib.h"
|
||||
#include "string.h"
|
||||
#include "terminal.h"
|
||||
|
||||
#include <stdarg.h>
|
||||
|
||||
static int get_level(const char *str)
|
||||
{
|
||||
if (!str || !isdigit(str[0]))
|
||||
return 8;
|
||||
return str[0] - '0';
|
||||
}
|
||||
|
||||
static int print_flag(char flag, va_list *ap)
|
||||
{
|
||||
switch (flag) {
|
||||
@ -23,12 +27,15 @@ static int print_flag(char flag, va_list *ap)
|
||||
return 0;
|
||||
}
|
||||
|
||||
int kvprintf(int level, const char *restrict format, va_list ap)
|
||||
int kvprintf(const char *restrict format, va_list ap)
|
||||
{
|
||||
const char *start = format;
|
||||
int ret = 0;
|
||||
|
||||
(void)level;
|
||||
int level = get_level(format);
|
||||
set_color_level(level);
|
||||
if (level != 8)
|
||||
start++;
|
||||
while (*start != '\0') {
|
||||
if (*start == '%' && *(start + 1) != '\0') {
|
||||
ret += print_flag(*(start + 1), &ap);
|
||||
@ -38,6 +45,7 @@ int kvprintf(int level, const char *restrict format, va_list ap)
|
||||
}
|
||||
start++;
|
||||
}
|
||||
set_color_level(8);
|
||||
update_cursor();
|
||||
return ret;
|
||||
}
|
||||
|
Reference in New Issue
Block a user