diff options
Diffstat (limited to 'src/main/extractor_logging.c')
-rw-r--r-- | src/main/extractor_logging.c | 68 |
1 files changed, 68 insertions, 0 deletions
diff --git a/src/main/extractor_logging.c b/src/main/extractor_logging.c new file mode 100644 index 0000000..449ffbe --- /dev/null +++ b/src/main/extractor_logging.c | |||
@@ -0,0 +1,68 @@ | |||
1 | /* | ||
2 | This file is part of libextractor. | ||
3 | (C) 2012 Vidyut Samanta and Christian Grothoff | ||
4 | |||
5 | libextractor is free software; you can redistribute it and/or modify | ||
6 | it under the terms of the GNU General Public License as published | ||
7 | by the Free Software Foundation; either version 3, or (at your | ||
8 | option) any later version. | ||
9 | |||
10 | libextractor 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 libextractor; see the file COPYING. If not, write to the | ||
17 | Free Software Foundation, Inc., 59 Temple Place - Suite 330, | ||
18 | Boston, MA 02111-1307, USA. | ||
19 | */ | ||
20 | /** | ||
21 | * @file main/extractor_logging.c | ||
22 | * @brief logging API for GNU libextractor | ||
23 | * @author Christian Grothoff | ||
24 | */ | ||
25 | #include "platform.h" | ||
26 | #include "extractor_logging.h" | ||
27 | |||
28 | #if DEBUG | ||
29 | /** | ||
30 | * Log function. | ||
31 | * | ||
32 | * @param file name of file with the error | ||
33 | * @param line line number with the error | ||
34 | * @param ... log message and arguments | ||
35 | */ | ||
36 | void | ||
37 | EXTRACTOR_log_ (const char *file, int line, const char *format, ...) | ||
38 | { | ||
39 | va_list va; | ||
40 | |||
41 | fprintf (stderr, | ||
42 | sizeof (file_line), | ||
43 | "EXTRACTOR %s:%d "); | ||
44 | va_start (va, format); | ||
45 | vfprintf (stderr, format, va); | ||
46 | va_end (va); | ||
47 | fflush (stderr); | ||
48 | } | ||
49 | #endif | ||
50 | |||
51 | |||
52 | /** | ||
53 | * Abort the program reporting an assertion failure | ||
54 | * | ||
55 | * @param file filename with the failure | ||
56 | * @param line line number with the failure | ||
57 | */ | ||
58 | void | ||
59 | EXTRACTOR_abort_ (const char *file, | ||
60 | int line) | ||
61 | { | ||
62 | #if DEBUG | ||
63 | EXTRACTOR_log_ (file, line, "Assertion failed.\n"); | ||
64 | #endif | ||
65 | abort (); | ||
66 | } | ||
67 | |||
68 | /* end of extractor_logging.c */ | ||