chiark / gitweb /
Switch to GPL v3
[disorder] / lib / log-impl.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 /** @file lib/log-impl.h @brief Errors and logging */
19
20 /** @brief Log an error and quit
21  *
22  * If @c ${DISORDER_FATAL_ABORT} is defined (as anything) then the process
23  * is aborted, so you can get a backtrace.
24  */
25 void disorder_fatal(int errno_value, const char *msg, ...) {
26   va_list ap;
27
28   va_start(ap, msg);
29   elog(LOG_CRIT, errno_value, msg, ap);
30   va_end(ap);
31   if(getenv("DISORDER_FATAL_ABORT")) abort();
32   exitfn(EXIT_FAILURE);
33 }
34
35 /** @brief Log an error */
36 void disorder_error(int errno_value, const char *msg, ...) {
37   va_list ap;
38
39   va_start(ap, msg);
40   elog(LOG_ERR, errno_value, msg, ap);
41   va_end(ap);
42 }
43
44 /** @brief Log an informational message */
45 void disorder_info(const char *msg, ...) {
46   va_list ap;
47
48   va_start(ap, msg);
49   elog(LOG_INFO, 0, msg, ap);
50   va_end(ap);
51 }
52
53 /*
54 Local Variables:
55 c-basic-offset:2
56 comment-column:40
57 End:
58 */