More flexible logging subsystem
[notion/jeffpc.git] / ioncore / log.c
blobd8452020d79eab93b9971e67d14d24316aec49ab
1 /*
2 * ion/ioncore/log.c
4 * Copyright (c) the Notion team 2013
6 * See the included file LICENSE for details.
7 */
9 #include <stdarg.h>
10 #include <stddef.h>
11 #include <stdio.h>
12 #include "log.h"
14 /** For this category, show log messages at this loglevel and above */
15 LogLevel minimumLevel(LogCategory category)
17 switch(category){
18 case FONT:
19 /** For https://sourceforge.net/p/notion/bugs/63/ */
20 return DEBUG;
21 default:
22 return INFO;
26 void vlog_message(LogLevel level, LogCategory category, const char *file, int line, const char* message, va_list argp)
28 if(level >= minimumLevel(category)){
29 fprintf(stderr, "Notion: ");
30 if(file!=NULL)
31 fprintf(stderr, "%s:%d: ", file, line);
32 vfprintf(stderr, message, argp);
33 fprintf(stderr, "\n");
37 void log_message(LogLevel level, LogCategory category, const char *file, int line, const char* message, ...)
39 va_list argp;
40 va_start(argp, message);
41 vlog_message(level, category, file, line, message, argp);
42 va_end(argp);
45 #if __STDC_VERSION__ < 199901L
46 extern void LOG(LogLevel level, LogCategory category, const char* message, ...)
48 va_list argp;
49 va_start(argp, message);
50 vlog_message(level, category, NULL, -1, message, argp);
51 va_end(argp);
53 #endif