-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlog.h
64 lines (51 loc) · 1.21 KB
/
log.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
/*
* log.h
*
* Copyright 2007 Jean-Marc Saffroy <[email protected]>
* This file is part of the Driller library.
* Driller is free software, distributed under the terms of the
* GNU Lesser General Public License version 2.1.
*
*/
#ifndef LOG_H
#define LOG_H
/*
* traces
*/
#include <stdio.h>
#include <errno.h>
#include <string.h>
#include <stdlib.h>
#define err_noabort(fmt,arg...) \
do { \
fprintf(stderr, "error(%s:%d:%s): " fmt "\n", \
__FILE__, __LINE__, __FUNCTION__, ##arg); \
} while(0)
#define err(fmt,arg...) \
do { \
err_noabort(fmt, ##arg); \
abort(); \
} while(0)
#define perr(str) err(str ":%s\n", strerror(errno))
#define perr_noabort(str) err_noabort(str ":%s\n", strerror(errno))
#define warn(fmt,arg...) \
fprintf(stderr, "warning(%s:%d:%s): " fmt "\n", \
__FILE__, __LINE__, __FUNCTION__, ##arg)
#ifdef DEBUG
#define dbg(fmt,arg...) \
fprintf(stderr, "debug(%s:%d:%s): " fmt "\n", \
__FILE__, __LINE__, __FUNCTION__, ##arg)
#else
#define dbg(fmt,arg...) do { } while(0)
#endif
#ifdef DEBUG2
#define dbg2 dbg
#else
#define dbg2(fmt,arg...) do { } while(0)
#endif
/*
* utilities
*/
#define min(x,y) (x < y ? x : y)
#define max(x,y) (x > y ? x : y)
#endif /* LOG_H */