-
Notifications
You must be signed in to change notification settings - Fork 18
/
debug.h
70 lines (61 loc) · 1.6 KB
/
debug.h
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
#ifndef IQDB_DEBUG_H
#define IQDB_DEBUG_H
#include <time.h>
#include <unistd.h>
#include <sys/time.h>
#define DEBUG_OUT stderr
#define DEBUG(v) if (debug_level & DEBUG_ ## v) debug
#define DEBUG_CONT(v) if (debug_level & DEBUG_ ## v) fprintf
#define DEF_DEBUG(v, n) \
static const int DEBUG_ ## v = 1 << n; \
static const int DEBUG_ ## n = 1;
DEF_DEBUG(errors, 0) // XX
DEF_DEBUG(base, 1) // XX
DEF_DEBUG(summary, 2) // XX
DEF_DEBUG(terse, 3) // X
DEF_DEBUG(warnings, 4)
#ifdef DEBUG_DLER
DEF_DEBUG(transfers, 5) // X
DEF_DEBUG(prot_err, 6)
DEF_DEBUG(connections, 7)
DEF_DEBUG(tasks, 8)
DEF_DEBUG(curl, 10)
DEF_DEBUG(sockets, 11)
DEF_DEBUG(timers, 12)
DEF_DEBUG(events, 13)
DEF_DEBUG(output, 14)
DEF_DEBUG(headers, 15)
DEF_DEBUG(redirects, 16)
DEF_DEBUG(requests, 17)
DEF_DEBUG(io, 18)
DEF_DEBUG(reads, 19)
DEF_DEBUG(protocol, 20)
DEF_DEBUG(iqdb, 21)
#endif
#ifdef DEBUG_IQDB
DEF_DEBUG(connections, 7)
DEF_DEBUG(images, 8)
DEF_DEBUG(dupe_finder, 10)
DEF_DEBUG(commands, 11)
#endif
#ifdef DEBUG_IPV6
DEF_DEBUG(connections, 7)
DEF_DEBUG(libevent, 10)
DEF_DEBUG(events, 13)
DEF_DEBUG(packets, 16)
DEF_DEBUG(io, 18)
DEF_DEBUG(addresses, 21)
#endif
DEF_DEBUG(resizer, 22)
DEF_DEBUG(image_info, 23)
DEF_DEBUG(prescale, 24)
DEF_DEBUG(imgdb, 25)
DEF_DEBUG(urlparse, 26)
DEF_DEBUG(queryqueue, 27)
static inline timeval now() { timeval tv; gettimeofday(&tv, NULL); return tv; }
static inline float elapsed(const timeval& from, const timeval& to = now()) {
return (to.tv_sec - from.tv_sec) + ((float)(to.tv_usec - from.tv_usec))/1e6;
}
__attribute__ ((format (printf, 1, 2)))
void debug(const char fmt[], ...);
#endif // IQDB_DEBUG_H