summaryrefslogtreecommitdiff
path: root/lib/logger/log.c
blob: c9bb652d1be5d76e62d92c55fa0b19bcd3127784 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
#include "log.h"
#include <stdarg.h>
#include "lib/int/stdint.h"

void PutConsole(char *str, int color, va_list va);

volatile uint64_t task_system_clock; // in task.c

void log(char *module_name, int log_level, char *format_string, ...)
{

    if(log_level<FOOLOS_LOG_INFO)return;

    char buf[10];
    uint32_t t=task_system_clock;
    uint32_t s=t/25;
    uint32_t ms=t*1000/25-1000*s;

    tfp_sprintf(buf,"[%6d.%05d] ",s,ms);

    PutConsole(buf,0b0111101111101111,task_system_clock);
    PutConsole(module_name,0b1111100000000000,0);
    PutConsole(": ",0b0000011111100000,0);
    va_list va;
    va_start(va,format_string);
    //PutConsole(format_string, 0b11111,  va); // blue
    PutConsole(format_string, 0b0111101111111111,  va);
    va_end(va);
    PutConsoleNL();

    
}

void panic(char *module_name,  char *format_string)
{

    PutConsole("!! KERNEL PANIC !! ",0b1111100000000000,0);
    PutConsole(module_name,0b1111100000000000,0);
    PutConsole(" : ",0b0000011111100000,0);
    PutConsole(format_string,0b1111100000000000,0);

    while(1); // halt
    
}