-
Notifications
You must be signed in to change notification settings - Fork 59
/
log.c
76 lines (67 loc) · 1.65 KB
/
log.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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
#include "log.h"
#include "config.h"
#include "util.h"
#include <curl/curl.h>
#include <stdarg.h>
#include <stdio.h>
#include <stdlib.h>
int log_level_init(void)
{
char *env = getenv("HTTPDIRFS_LOG_LEVEL");
if (env) {
return atoi(env);
}
#ifdef DEBUG
return DEFAULT_LOG_LEVEL | debug;
#else
return DEFAULT_LOG_LEVEL;
#endif
}
void
log_printf(LogType type, const char *file, const char *func, int line,
const char *format, ...)
{
if (type & CONFIG.log_type) {
switch (type) {
case fatal:
fprintf(stderr, "Fatal:");
break;
case error:
fprintf(stderr, "Error:");
break;
case warning:
fprintf(stderr, "Warning:");
break;
case info:
goto print_actual_message;
default:
fprintf(stderr, "Debug");
if (type != debug) {
fprintf(stderr, "(%x)", type);
}
fprintf(stderr, ":");
break;
}
fprintf(stderr, "%s:%d:", file, line);
print_actual_message: {
}
fprintf(stderr, "%s: ", func);
va_list args;
va_start(args, format);
vfprintf(stderr, format, args);
va_end(args);
if (type == fatal) {
exit_failure();
}
}
}
void print_version(void)
{
/* FUSE prints its help to stderr */
fprintf(stderr, "HTTPDirFS version " VERSION "\n");
/*
* --------- Print off SSL engine version ---------
*/
curl_version_info_data *data = curl_version_info(CURLVERSION_NOW);
fprintf(stderr, "libcurl SSL engine: %s\n", data->ssl_version);
}