chiark / gitweb /
Doxygen-clean
[disorder] / lib / log.h
CommitLineData
460b9539 1/*
2 * This file is part of DisOrder.
5aff007d 3 * Copyright (C) 2004, 2005, 2007, 2008 Richard Kettlewell
460b9539 4 *
e7eb3a27 5 * This program is free software: you can redistribute it and/or modify
460b9539 6 * it under the terms of the GNU General Public License as published by
e7eb3a27 7 * the Free Software Foundation, either version 3 of the License, or
460b9539 8 * (at your option) any later version.
e7eb3a27
RK
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 *
460b9539 15 * You should have received a copy of the GNU General Public License
e7eb3a27 16 * along with this program. If not, see <http://www.gnu.org/licenses/>.
460b9539 17 */
18
19#ifndef LOG_H
20#define LOG_H
21
460b9539 22#include <stdarg.h>
23
24struct log_output;
25
26void set_progname(char **argv);
460b9539 27
28void elog(int pri, int errno_value, const char *fmt, va_list ap);
460b9539 29
30void fatal(int errno_value, const char *msg, ...) attribute((noreturn))
31 attribute((format (printf, 2, 3)));
32void error(int errno_value, const char *msg, ...)
33 attribute((format (printf, 2, 3)));
34void info(const char *msg, ...)
35 attribute((format (printf, 1, 2)));
36void 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
41extern int debugging;
42/* set when debugging enabled */
43
44extern void (*exitfn)(int) attribute((noreturn));
45/* how to exit the program (for fatal) */
46
47extern const char *progname;
48/* program name */
49
50extern struct log_output log_stderr, log_syslog, *log_default;
51/* some typical outputs */
52
53extern const char *debug_filename;
54extern 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/*
67Local Variables:
68c-basic-offset:2
69comment-column:40
70fill-column:79
71End:
72*/