OpenDNSSEC-signer  1.4.8.2
log.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2009 NLnet Labs. All rights reserved.
3  *
4  * Redistribution and use in source and binary forms, with or without
5  * modification, are permitted provided that the following conditions
6  * are met:
7  * 1. Redistributions of source code must retain the above copyright
8  * notice, this list of conditions and the following disclaimer.
9  * 2. Redistributions in binary form must reproduce the above copyright
10  * notice, this list of conditions and the following disclaimer in the
11  * documentation and/or other materials provided with the distribution.
12  *
13  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
14  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
15  * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
16  * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
17  * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
18  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
19  * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
20  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
21  * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
22  * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
23  * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
24  *
25  */
26 
32 #ifndef SHARED_LOG_H
33 #define SHARED_LOG_H
34 
35 #include "config.h"
36 
37 #include <stdio.h>
38 #include <stdarg.h>
39 
40 #ifdef HAVE_SYSLOG_H
41 #include <strings.h> /* strncasecmp() */
42 #include <syslog.h> /* openlog(), closelog(), syslog() */
43 #else /* !HAVE_SYSLOG_H */
44 #define LOG_EMERG 0 /* ods_fatal_exit */
45 #define LOG_ALERT 1 /* ods_log_alert */
46 #define LOG_CRIT 2 /* ods_log_crit */
47 #define LOG_ERR 3 /* ods_log_error */
48 #define LOG_WARNING 4 /* ods_log_warning */
49 #define LOG_NOTICE 5 /* ods_log_info */
50 #define LOG_INFO 6 /* ods_log_verbose */
51 #define LOG_DEBUG 7 /* ods_log_debug */
52 #endif /* HAVE_SYSLOG_H */
53 #define LOG_DEEEBUG 8 /* ods_log_deeebug */
54 
62 void ods_log_init(const char *filename, int use_syslog, int verbosity);
63 
68 void ods_log_close(void);
69 
76 int ods_log_get_facility(const char* facility);
77 
83 int ods_log_get_level();
84 
90 void ods_log_deeebug(const char *format, ...);
91 
97 void ods_log_debug(const char *format, ...);
98 
104 void ods_log_verbose(const char *format, ...);
105 
111 void ods_log_info(const char *format, ...);
112 
118 void ods_log_warning(const char *format, ...);
119 
125 void ods_log_error(const char *format, ...);
126 
132 void ods_log_crit(const char *format, ...);
133 
139 void ods_log_alert(const char *format, ...);
140 
146 void ods_fatal_exit(const char *format, ...);
147 
152 #define ODS_LOG_DEBUG 1
153 #ifdef ODS_LOG_DEBUG
154 #define ods_log_assert(x) \
155  do { if(!(x)) \
156  ods_fatal_exit("%s:%d: %s: assertion %s failed", \
157  __FILE__, __LINE__, __func__, #x); \
158  } while(0);
159 
160 #else
161 #define ods_log_assert(x)
162 #endif
163 
164 #endif /* SHARED_LOG_H */
void ods_log_close(void)
Definition: log.c:136
void ods_log_error(const char *format,...)
Definition: log.c:334
void ods_log_crit(const char *format,...)
Definition: log.c:350
void ods_log_deeebug(const char *format,...)
Definition: log.c:254
int ods_log_get_facility(const char *facility)
int ods_log_get_level()
Definition: log.c:207
void ods_log_alert(const char *format,...)
Definition: log.c:366
void ods_fatal_exit(const char *format,...)
Definition: log.c:382
void ods_log_init(const char *filename, int use_syslog, int verbosity)
Definition: log.c:81
void ods_log_warning(const char *format,...)
Definition: log.c:318
void ods_log_verbose(const char *format,...)
Definition: log.c:286
void ods_log_debug(const char *format,...)
Definition: log.c:270
void ods_log_info(const char *format,...)
Definition: log.c:302