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