]> andersk Git - test.git/blob - logging/logging.h
Use 2048-bit RSA keys for auto-generated certificates.
[test.git] / logging / logging.h
1 // logging.h -- Utility functions for managing log messages
2 // Copyright (C) 2008-2009 Markus Gutschke <markus@shellinabox.com>
3 //
4 // This program is free software; you can redistribute it and/or modify
5 // it under the terms of the GNU General Public License version 2 as
6 // published by the Free Software Foundation.
7 //
8 // This program is distributed in the hope that it will be useful,
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
11 // GNU General Public License for more details.
12 //
13 // You should have received a copy of the GNU General Public License along
14 // with this program; if not, write to the Free Software Foundation, Inc.,
15 // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
16 //
17 // In addition to these license terms, the author grants the following
18 // additional rights:
19 //
20 // If you modify this program, or any covered work, by linking or
21 // combining it with the OpenSSL project's OpenSSL library (or a
22 // modified version of that library), containing parts covered by the
23 // terms of the OpenSSL or SSLeay licenses, the author
24 // grants you additional permission to convey the resulting work.
25 // Corresponding Source for a non-source form of such a combination
26 // shall include the source code for the parts of OpenSSL used as well
27 // as that of the covered work.
28 //
29 // You may at your option choose to remove this additional permission from
30 // the work, or from any part of it.
31 //
32 // It is possible to build this program in a way that it loads OpenSSL
33 // libraries at run-time. If doing so, the following notices are required
34 // by the OpenSSL and SSLeay licenses:
35 //
36 // This product includes software developed by the OpenSSL Project
37 // for use in the OpenSSL Toolkit. (http://www.openssl.org/)
38 //
39 // This product includes cryptographic software written by Eric Young
40 // (eay@cryptsoft.com)
41 //
42 //
43 // The most up-to-date version of this program is always available from
44 // http://shellinabox.com
45
46 #ifndef LOGGING_H__
47 #define LOGGING_H__
48
49 #include <stdarg.h>
50
51 #define MSG_QUIET  -1
52 #define MSG_MESSAGE 0
53 #define MSG_ERROR   1
54 #define MSG_WARN    2
55 #define MSG_INFO    3
56 #define MSG_DEBUG   4
57 #define MSG_DEFAULT MSG_ERROR
58
59 #define check(x)  do {                                                        \
60                     if (!(x))                                                 \
61                       fatal("Check failed at "__FILE__":%d in %s(): %s",      \
62                              __LINE__, __func__, #x);                         \
63                   } while (0)
64
65 #define dcheck(x) do {                                                        \
66                     if (!(x))                                                 \
67                       (logIsDebug() ? fatal : error)(                         \
68                             "Check failed at "__FILE__":%d in %s(): %s",      \
69                              __LINE__, __func__, #x);                         \
70                   } while (0)
71
72 void debug(const char *fmt, ...)   __attribute__((format(printf, 1, 2)));
73 void info(const char *fmt, ...)    __attribute__((format(printf, 1, 2)));
74 void warn(const char *fmt, ...)    __attribute__((format(printf, 1, 2)));
75 void error(const char *fmt, ...)   __attribute__((format(printf, 1, 2)));
76 void message(const char *fmt, ...) __attribute__((format(printf, 1, 2)));
77 void fatal(const char *fmt, ...)   __attribute__((format(printf, 1, 2),
78                                                   noreturn));
79 int logIsDebug(void);
80 int logIsInfo(void);
81 int logIsWarn(void);
82 int logIsError(void);
83 int logIsMessage(void);
84 int logIsQuiet(void);
85 int logIsDefault(void);
86 int logIsVerbose(void);
87 void logSetLogLevel(int level);
88
89 char *vStringPrintf(char *buf, const char *fmt, va_list ap);
90 char *stringPrintf(char *buf, const char *fmt, ...)
91   __attribute__((format(printf, 2, 3)));
92 char *stringPrintfUnchecked(char *buf, const char *fmt, ...);
93
94 #endif /* LOGGING_H__ */
This page took 0.077948 seconds and 5 git commands to generate.