1 |
/* Definitions and prototypes related to logging. |
2 |
* |
3 |
* IRC Services is copyright (c) 1996-2009 Andrew Church. |
4 |
* E-mail: <achurch@achurch.org> |
5 |
* Parts written by Andrew Kempe and others. |
6 |
* This program is free but copyrighted software; see the file GPL.txt for |
7 |
* details. |
8 |
*/ |
9 |
|
10 |
|
11 |
#ifndef LOG_H |
12 |
#define LOG_H |
13 |
|
14 |
extern void set_logfile(const char *pattern); |
15 |
extern int open_log(void); |
16 |
extern int open_memory_log(void); |
17 |
extern void close_log(void); |
18 |
extern int reopen_log(void); |
19 |
extern int log_is_open(void); |
20 |
extern void do_log(int debuglevel, int do_perror, const char *modulename, |
21 |
const char *fmt, ...) |
22 |
FORMAT(printf,4,5); |
23 |
extern void fatal(const char *fmt, ...) |
24 |
FORMAT(printf,1,2); |
25 |
extern void fatal_perror(const char *fmt, ...) |
26 |
FORMAT(printf,1,2); |
27 |
|
28 |
#undef log /* in case system includes #define it */ |
29 |
#define log(fmt,...) \ |
30 |
log_debug(0, fmt , ##__VA_ARGS__) |
31 |
#define log_perror(fmt,...) \ |
32 |
log_perror_debug(0, fmt , ##__VA_ARGS__) |
33 |
#define log_debug(debuglevel,fmt,...) \ |
34 |
do_log(debuglevel, 0, NULL, fmt, ##__VA_ARGS__) |
35 |
#define log_perror_debug(debuglevel,fmt,...) \ |
36 |
do_log(debuglevel, 1, NULL, fmt, ##__VA_ARGS__) |
37 |
#define module_log(fmt,...) \ |
38 |
module_log_debug(0, fmt , ##__VA_ARGS__) |
39 |
#define module_log_perror(fmt,...) \ |
40 |
module_log_perror_debug(0, fmt , ##__VA_ARGS__) |
41 |
#define module_log_debug(debuglevel,fmt,...) \ |
42 |
do_log(debuglevel, 0, MODULE_NAME, fmt, ##__VA_ARGS__) |
43 |
#define module_log_perror_debug(debuglevel,fmt,...) \ |
44 |
do_log(debuglevel, 1, MODULE_NAME, fmt, ##__VA_ARGS__) |
45 |
|
46 |
#endif /* LOG_H */ |
47 |
|
48 |
/* |
49 |
* Local variables: |
50 |
* c-file-style: "stroustrup" |
51 |
* c-file-offsets: ((case-label . *) (statement-case-intro . *)) |
52 |
* indent-tabs-mode: nil |
53 |
* End: |
54 |
* |
55 |
* vim: expandtab shiftwidth=4: |
56 |
*/ |