-
Notifications
You must be signed in to change notification settings - Fork 0
/
aollog.c
61 lines (51 loc) · 1.18 KB
/
aollog.c
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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
#include "params.h"
#include <fuse.h>
#include <stdarg.h>
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <sys/types.h>
#include <sys/stat.h>
#include "aollog.h"
#define LOG_ENABLED 1
#define OFF 0
#define NORMAL 1
#define DEBUG 2
#define UBERDEBUG 3
static int aol_log_level = UBERDEBUG;
FILE *log_open()
{
FILE *logfile;
//This should be configurable. and disableable
logfile = fopen("atmos_fuse.log", "w");
if (NULL == logfile) {
exit(EXIT_FAILURE);
}
setvbuf(logfile, NULL, _IOLBF, 0);
return logfile;
}
void log_msg( const int level,const char *format, ...)
{
va_list ap;
va_start(ap, format);
if(LOG_ENABLED && level <= aol_log_level)
vfprintf(ATMOS_DATA->logfile, format, ap);
}
void log_normal(const char *format, ...) {
va_list ap;
va_start(ap, format);
log_msg(NORMAL,format, ap);
}
void log_debug(const char *format, ...) {
va_list ap;
va_start(ap, format);
log_msg(DEBUG,format, ap);
}
void log_uberdebug(const char *format, ...) {
va_list ap;
va_start(ap, format);
log_msg(UBERDEBUG,format, ap);
}
void setup_log(int loglevel) {
aol_log_level = loglevel;
}