Commit | Line | Data |
---|---|---|
460b9539 | 1 | /* |
2 | * This file is part of DisOrder. | |
3 | * Copyright (C) 2004, 2005 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 2 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, but | |
11 | * WITHOUT ANY WARRANTY; without even the implied warranty of | |
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
13 | * 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, write to the Free Software | |
17 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 | |
18 | * USA | |
19 | */ | |
14ad73b9 | 20 | /** @file lib/log-impl.h @brief Errors and logging */ |
460b9539 | 21 | |
14ad73b9 RK |
22 | /** @brief Log an error and quit |
23 | * | |
24 | * If @c ${DISORDER_FATAL_ABORT} is defined (as anything) then the process | |
25 | * is aborted, so you can get a backtrace. | |
26 | */ | |
460b9539 | 27 | void disorder_fatal(int errno_value, const char *msg, ...) { |
28 | va_list ap; | |
29 | ||
30 | va_start(ap, msg); | |
31 | elog(LOG_CRIT, errno_value, msg, ap); | |
32 | va_end(ap); | |
33 | if(getenv("DISORDER_FATAL_ABORT")) abort(); | |
34 | exitfn(EXIT_FAILURE); | |
35 | } | |
36 | ||
14ad73b9 | 37 | /** @brief Log an error */ |
460b9539 | 38 | void disorder_error(int errno_value, const char *msg, ...) { |
39 | va_list ap; | |
40 | ||
41 | va_start(ap, msg); | |
42 | elog(LOG_ERR, errno_value, msg, ap); | |
43 | va_end(ap); | |
44 | } | |
45 | ||
14ad73b9 | 46 | /** @brief Log an informational message */ |
460b9539 | 47 | void disorder_info(const char *msg, ...) { |
48 | va_list ap; | |
49 | ||
50 | va_start(ap, msg); | |
51 | elog(LOG_INFO, 0, msg, ap); | |
52 | va_end(ap); | |
53 | } | |
54 | ||
55 | /* | |
56 | Local Variables: | |
57 | c-basic-offset:2 | |
58 | comment-column:40 | |
59 | End: | |
60 | */ |