OpenDNSSEC-signer  1.4.1
log.h
Go to the documentation of this file.
1 /*
2  * $Id: log.h 3845 2010-08-31 14:19:24Z matthijs $
3  *
4  * Copyright (c) 2009 NLnet Labs. All rights reserved.
5  *
6  * Redistribution and use in source and binary forms, with or without
7  * modification, are permitted provided that the following conditions
8  * are met:
9  * 1. Redistributions of source code must retain the above copyright
10  * notice, this list of conditions and the following disclaimer.
11  * 2. Redistributions in binary form must reproduce the above copyright
12  * notice, this list of conditions and the following disclaimer in the
13  * documentation and/or other materials provided with the distribution.
14  *
15  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
16  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
17  * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
18  * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
19  * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
20  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
21  * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
22  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
23  * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
24  * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
25  * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26  *
27  */
28 
34 #ifndef SHARED_LOG_H
35 #define SHARED_LOG_H
36 
37 #include "config.h"
38 
39 #include <stdio.h>
40 #include <stdarg.h>
41 
42 #ifdef HAVE_SYSLOG_H
43 #include <strings.h> /* strncasecmp() */
44 #include <syslog.h> /* openlog(), closelog(), syslog() */
45 #else /* !HAVE_SYSLOG_H */
46 #define LOG_EMERG 0 /* ods_fatal_exit */
47 #define LOG_ALERT 1 /* ods_log_alert */
48 #define LOG_CRIT 2 /* ods_log_crit */
49 #define LOG_ERR 3 /* ods_log_error */
50 #define LOG_WARNING 4 /* ods_log_warning */
51 #define LOG_NOTICE 5 /* ods_log_info */
52 #define LOG_INFO 6 /* ods_log_verbose */
53 #define LOG_DEBUG 7 /* ods_log_debug */
54 #endif /* HAVE_SYSLOG_H */
55 #define LOG_DEEEBUG 8 /* ods_log_deeebug */
56 
64 void ods_log_init(const char *filename, int use_syslog, int verbosity);
65 
70 void ods_log_close(void);
71 
78 int ods_log_get_facility(const char* facility);
79 
85 int ods_log_get_level();
86 
92 void ods_log_deeebug(const char *format, ...);
93 
99 void ods_log_debug(const char *format, ...);
100 
106 void ods_log_verbose(const char *format, ...);
107 
113 void ods_log_info(const char *format, ...);
114 
120 void ods_log_warning(const char *format, ...);
121 
127 void ods_log_error(const char *format, ...);
128 
134 void ods_log_crit(const char *format, ...);
135 
141 void ods_log_alert(const char *format, ...);
142 
148 void ods_fatal_exit(const char *format, ...);
149 
154 #define ODS_LOG_DEBUG 1
155 #ifdef ODS_LOG_DEBUG
156 #define ods_log_assert(x) \
157  do { if(!(x)) \
158  ods_fatal_exit("%s:%d: %s: assertion %s failed", \
159  __FILE__, __LINE__, __func__, #x); \
160  } while(0);
161 
162 #else
163 #define ods_log_assert(x)
164 #endif
165 
166 #endif /* SHARED_LOG_H */