toaruos/kernel/misc/logging.c

40 lines
802 B
C
Raw Normal View History

2011-12-15 03:47:30 +04:00
/* vim: tabstop=4 shiftwidth=4 noexpandtab
*
* Kernel Logging Facility
*
* Maintains a log in-memory as well as to serial (unless
* told not to).
*/
#include <system.h>
#include <list.h>
#include <logging.h>
2011-12-15 05:19:51 +04:00
#include <va_list.h>
2011-12-15 03:47:30 +04:00
log_type_t debug_level = NOTICE;
static char * c_messages[] = {
"\033[1;34mINFO",
"\033[1;35mNOTICE",
"\033[1;33mWARNING",
"\033[1;31mERROR",
2013-06-06 10:10:36 +04:00
"\033[1;37;41mCRITICAL",
"\033[1;31;44mINSANE"
};
void _debug_print(char * title, int line_no, log_type_t level, char *fmt, ...) {
if (level >= debug_level) {
va_list args;
va_start(args, fmt);
char buffer[1024];
vasprintf(buffer, fmt, args);
va_end(args);
2012-12-08 07:06:43 +04:00
kprintf("[%10d.%2d:%s:%d] %s\033[0m: %s\n", timer_ticks, timer_subticks, title, line_no, c_messages[level], buffer);
}
/* else ignore */
}