#include "log.h" #include #include #include "kernel/kernel.h" #include "kernel/fifo.h" #include "driver/serial.h" #include "driver/timer.h" #include "lib/string/string.h" #include "lib/printf/printf.h" static void log_string(char *str) { // if(get_max_fd()>=2) syscall_write(2,str,strlen(str)); while(*str!=0) { serial_write(*str++); } } void log(char *module_name, int prio, char *format_string, ...) { #ifdef FOOLOS_LOG_OFF return; #endif char buf_info[256]; char buf_log[256]; char buf_time[20]; uint64_t t=timer_get_uptime_ms(); uint32_t ms=t%1000; uint32_t s=t/1000; tfp_sprintf(buf_time,"[%04d %03d]",s,ms); va_list va; va_start(va,format_string); tfp_vsprintf(buf_info,format_string,va); va_end(va); tfp_sprintf(buf_log,"\033[36;40m%s\033[31;40m %s:\033[37;40m %s\n",buf_time,module_name,buf_info); log_string(buf_log); } /* void panic(char *module_name, char *format_string) { char buf_log[256]; tfp_sprintf(buf_log,"\033[41;37m\n !! KERNEL PANIC !! %s: %s\n\n\033[37;40m",module_name,message); //PANIC DIRECTLY TO STDOUT// syscall_write(1,buf_log,strlen(buf_log)); log_string(buf_log); while(1) { asm volatile("cli"); asm volatile("hlt"); } } */