Commit | Line | Data |
---|---|---|
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 | */ |
14ad73b9 | 18 | /** @file lib/log-impl.h @brief Errors and logging */ |
460b9539 | 19 | |
14ad73b9 RK |
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 | */ | |
460b9539 | 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 | ||
14ad73b9 | 35 | /** @brief Log an error */ |
460b9539 | 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 | ||
14ad73b9 | 44 | /** @brief Log an informational message */ |
460b9539 | 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 | */ |