-
Notifications
You must be signed in to change notification settings - Fork 0
/
debug.h
41 lines (30 loc) · 843 Bytes
/
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
#ifndef __EGA_DIST_DEBUG_H_INCLUDED__
#define __EGA_DIST_DEBUG_H_INCLUDED__ 1
#include <stdlib.h>
#include <stddef.h>
#include <unistd.h>
#include <string.h>
#include <stdio.h>
#ifndef DEBUG
#error "You must define a debug level"
#endif
/* Ignore the logs */
#define __EGA_DIST_LOG_H_INCLUDED__ 1
#define DEBUG_FUNC(level, fmt, ...) fprintf(stderr, "%-10s(%3d) |" level " " fmt "\n", __FILE__, __LINE__, ##__VA_ARGS__)
#define E(fmt, ...) DEBUG_FUNC("ERROR", fmt, ##__VA_ARGS__)
#if DEBUG > 0
#define D1(fmt, ...) DEBUG_FUNC("", fmt, ##__VA_ARGS__)
#else
#define D1(...)
#endif
#if DEBUG > 1
#define D2(fmt, ...) DEBUG_FUNC(" ", fmt, ##__VA_ARGS__)
#else
#define D2(...)
#endif
#if DEBUG > 2
#define D3(fmt, ...) DEBUG_FUNC(" ", fmt, ##__VA_ARGS__)
#else
#define D3(...)
#endif
#endif /* !__EGA_DIST_DEBUG_H_INCLUDED__ */