]>
Commit | Line | Data |
---|---|---|
5899f3b7 LP |
1 | /*-*- Mode: C; c-basic-offset: 8 -*-*/ |
2 | ||
3 | #ifdef HAVE_CONFIG_H | |
4 | #include <config.h> | |
5 | #endif | |
6 | ||
7 | #include <stdarg.h> | |
8 | #include <stdio.h> | |
c9b97d2a | 9 | #include <errno.h> |
5899f3b7 LP |
10 | |
11 | #include "log.h" | |
12 | ||
13 | void log_meta( | |
14 | int level, | |
15 | const char*file, | |
16 | int line, | |
17 | const char *func, | |
18 | const char *format, ...) { | |
19 | ||
20 | const char *prefix, *suffix; | |
21 | va_list ap; | |
c9b97d2a | 22 | int saved_errno = errno; |
5899f3b7 LP |
23 | |
24 | if (LOG_PRI(level) <= LOG_ERR) { | |
25 | prefix = "\x1B[1;31m"; | |
26 | suffix = "\x1B[0m"; | |
27 | } else { | |
28 | prefix = ""; | |
29 | suffix = ""; | |
30 | } | |
31 | ||
32 | va_start(ap, format); | |
33 | ||
34 | fprintf(stderr, "(%s:%u) %s", file, line, prefix); | |
35 | vfprintf(stderr, format, ap); | |
36 | fprintf(stderr, "%s\n", suffix); | |
37 | ||
38 | va_end(ap); | |
39 | ||
c9b97d2a | 40 | errno = saved_errno; |
5899f3b7 | 41 | } |