]> git.sven.stormbind.net Git - sven/exfat-utils.git/blob - libexfat/log.c
New upstream release.
[sven/exfat-utils.git] / libexfat / log.c
1 /*
2         log.c (02.09.09)
3         exFAT file system implementation library.
4
5         Copyright (C) 2009, 2010  Andrew Nayenko
6
7         This program is free software: you can redistribute it and/or modify
8         it under the terms of the GNU General Public License as published by
9         the Free Software Foundation, either version 3 of the License, or
10         (at your option) any later version.
11
12         This program is distributed in the hope that it will be useful,
13         but WITHOUT ANY WARRANTY; without even the implied warranty of
14         MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15         GNU General Public License for more details.
16
17         You should have received a copy of the GNU General Public License
18         along with this program.  If not, see <http://www.gnu.org/licenses/>.
19 */
20
21 #include "exfat.h"
22 #include <stdarg.h>
23 #include <syslog.h>
24
25 int exfat_errors;
26
27 /*
28  * This message means an internal bug in exFAT implementation.
29  */
30 void exfat_bug(const char* format, ...)
31 {
32         va_list ap, aq;
33
34         va_start(ap, format);
35         va_copy(aq, ap);
36
37         fflush(stdout);
38         fputs("BUG: ", stderr);
39         vfprintf(stderr, format, ap);
40         va_end(ap);
41         fputs(".\n", stderr);
42
43         vsyslog(LOG_CRIT, format, aq);
44         va_end(aq);
45
46         abort();
47 }
48
49 /*
50  * This message means an error in exFAT file system.
51  */
52 void exfat_error(const char* format, ...)
53 {
54         va_list ap, aq;
55
56         exfat_errors++;
57         va_start(ap, format);
58         va_copy(aq, ap);
59
60         fflush(stdout);
61         fputs("ERROR: ", stderr);
62         vfprintf(stderr, format, ap);
63         va_end(ap);
64         fputs(".\n", stderr);
65
66         vsyslog(LOG_ERR, format, aq);
67         va_end(aq);
68 }
69
70 /*
71  * This message means that there is something unexpected in exFAT file system
72  * that can be a potential problem.
73  */
74 void exfat_warn(const char* format, ...)
75 {
76         va_list ap, aq;
77
78         va_start(ap, format);
79         va_copy(aq, ap);
80
81         fflush(stdout);
82         fputs("WARN: ", stderr);
83         vfprintf(stderr, format, ap);
84         va_end(ap);
85         fputs(".\n", stderr);
86
87         vsyslog(LOG_WARNING, format, aq);
88         va_end(aq);
89 }
90
91 /*
92  * Just debug message. Disabled by default.
93  */
94 void exfat_debug(const char* format, ...)
95 {
96         va_list ap;
97
98         fflush(stdout);
99         fputs("DEBUG: ", stderr);
100         va_start(ap, format);
101         vfprintf(stderr, format, ap);
102         va_end(ap);
103         fputs(".\n", stderr);
104 }