blob: 0481908227bc80cf9a2e1b9c8ffdb9f8d43b8176 (
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
|
#include <stdio.h>
#include <stdarg.h>
#include "logging.h"
int argent_log_level;
const char *level_string(int level)
{
switch(level) {
case FATAL:
return "FATAL";
case ERROR:
return "ERROR";
case WARN:
return "WARN";
case INFO:
return "INFO";
case DEBUG:
return "DEBUG";
case TRACE:
return "TRACE";
default:
if (level > TRACE)
return "TRACE";
return "[BAD LOG LEVEL]";
}
}
void argent_log(int level, const char *format_string, ...)
{
if (argent_log_level >= level) {
va_list args;
va_start(args, format_string);
fprintf(stderr, "[%s] ", level_string(level));
vfprintf(stderr, format_string, args);
fprintf(stderr, "\n");
va_end(args);
}
}
|