chiark / gitweb /
distcheck needs fiddled cgiexecdir too
[disorder] / lib / log.h
1 /*
2  * This file is part of DisOrder.
3  * Copyright (C) 2004, 2005, 2007, 2008 Richard Kettlewell
4  *
5  * This program is free software: you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License as published by
7  * the Free Software Foundation, either version 3 of the License, or
8  * (at your option) any later version.
9  * 
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13  * GNU General Public License for more details.
14  * 
15  * You should have received a copy of the GNU General Public License
16  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
17  */
18
19 #ifndef LOG_H
20 #define LOG_H
21
22 #include <stdarg.h>
23
24 struct log_output;
25
26 void set_progname(char **argv);
27
28 void elog(int pri, int errno_value, const char *fmt, va_list ap);
29
30 void fatal(int errno_value, const char *msg, ...) attribute((noreturn))
31   attribute((format (printf, 2, 3)));
32 void error(int errno_value, const char *msg, ...)
33   attribute((format (printf, 2, 3)));
34 void info(const char *msg, ...)
35   attribute((format (printf, 1, 2)));
36 void debug(const char *msg, ...)
37   attribute((format (printf, 1, 2)));
38 /* report a message of the given class.  @errno_value@ if present an
39  * non-zero is included.  @fatal@ terminates the process. */
40
41 extern int debugging;
42 /* set when debugging enabled */
43
44 extern void (*exitfn)(int) attribute((noreturn));
45 /* how to exit the program (for fatal) */
46   
47 extern const char *progname;
48 /* program name */
49
50 extern struct log_output log_stderr, log_syslog, *log_default;
51 /* some typical outputs */
52
53 extern const char *debug_filename;
54 extern int debug_lineno;
55
56 #define D(x) do {                               \
57   if(debugging) {                               \
58     debug_filename=__FILE__;                    \
59     debug_lineno=__LINE__;                      \
60     debug x;                                    \
61   }                                             \
62 } while(0)
63
64 #endif /* LOG_H */
65
66 /*
67 Local Variables:
68 c-basic-offset:2
69 comment-column:40
70 fill-column:79
71 End:
72 */