forked from Kalpanika/x3f
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathx3f_printf.c
More file actions
41 lines (35 loc) · 724 Bytes
/
Copy pathx3f_printf.c
File metadata and controls
41 lines (35 loc) · 724 Bytes
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
/* X3F_PRINTF.C
*
* Library for printout, depending on seriousity level.
*
* Copyright 2015 - Roland and Erik Karlsson
* BSD-style - see doc/copyright.txt
*
*/
#include "x3f_printf.h"
#include <stdio.h>
#include <stdarg.h>
x3f_verbosity_t x3f_printf_level = INFO;
extern void x3f_printf(x3f_verbosity_t level, const char *fmt, ...)
{
va_list ap;
FILE *f = level > WARN ? stdout : stderr;
if (level > x3f_printf_level) return;
switch(level) {
case ERR:
fprintf(f, "ERR: ");
break;
case WARN:
fprintf(f, "WRN: ");
break;
case INFO:
fprintf(f, " : ");
break;
case DEBUG:
fprintf(f, "dbg: ");
break;
}
va_start(ap, fmt);
vfprintf(f, fmt, ap);
va_end(ap);
}