Electroneum
log.h
Go to the documentation of this file.
1 /*
2  * util/log.h - logging service
3  *
4  * Copyright (c) 2007, NLnet Labs. All rights reserved.
5  *
6  * This software is open source.
7  *
8  * Redistribution and use in source and binary forms, with or without
9  * modification, are permitted provided that the following conditions
10  * are met:
11  *
12  * Redistributions of source code must retain the above copyright notice,
13  * this list of conditions and the following disclaimer.
14  *
15  * Redistributions in binary form must reproduce the above copyright notice,
16  * this list of conditions and the following disclaimer in the documentation
17  * and/or other materials provided with the distribution.
18  *
19  * Neither the name of the NLNET LABS nor the names of its contributors may
20  * be used to endorse or promote products derived from this software without
21  * specific prior written permission.
22  *
23  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
24  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
25  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
26  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
27  * HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
28  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
29  * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
30  * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
31  * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
32  * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34  */
35 
42 #ifndef UTIL_LOG_H
43 #define UTIL_LOG_H
44 struct sldns_buffer;
45 
62 };
63 
65 extern enum verbosity_value verbosity;
66 
74 void verbose(enum verbosity_value level,
75  const char* format, ...) ATTR_FORMAT(printf, 2, 3);
76 
83 void log_init(const char* filename, int use_syslog, const char* chrootdir);
84 
90 void log_file(FILE *f);
91 
98 void log_thread_set(int* num);
99 
107 int log_thread_get(void);
108 
113 void log_ident_set(const char* id);
114 
120 void log_set_time(time_t* t);
121 
128 void log_set_time_asc(int use_asc);
129 
131 void* log_get_lock(void);
132 
138 void log_info(const char* format, ...) ATTR_FORMAT(printf, 1, 2);
139 
145 void log_err(const char* format, ...) ATTR_FORMAT(printf, 1, 2);
146 
152 void log_warn(const char* format, ...) ATTR_FORMAT(printf, 1, 2);
153 
161 void log_hex(const char* msg, void* data, size_t length);
162 
170 void log_buf(enum verbosity_value level, const char* msg, struct sldns_buffer* buf);
171 
177 void fatal_exit(const char* format, ...) ATTR_FORMAT(printf, 1, 2);
178 
186 void log_vmsg(int pri, const char* type, const char* format, va_list args);
187 
191 #ifdef UNBOUND_DEBUG
192 #ifdef __clang_analyzer__
193 /* clang analyzer needs to know that log_assert is an assertion, otherwise
194  * it could complain about the nullptr the assert is guarding against. */
195 #define log_assert(x) assert(x)
196 #else
197 # define log_assert(x) \
198  do { if(!(x)) \
199  fatal_exit("%s:%d: %s: assertion %s failed", \
200  __FILE__, __LINE__, __func__, #x); \
201  } while(0);
202 #endif
203 #else
204 # define log_assert(x) /*nothing*/
205 #endif
206 
207 #ifdef USE_WINSOCK
208 
213 char* wsa_strerror(DWORD err);
214 #endif /* USE_WINSOCK */
215 
216 #endif /* UTIL_LOG_H */
Definition: log.h:53
void log_ident_set(const char *id)
enum verbosity_value verbosity
Definition: log.h:57
void void log_init(const char *filename, int use_syslog, const char *chrootdir)
void log_thread_set(int *num)
Definition: log.h:51
int log_thread_get(void)
void void log_err(const char *format,...) ATTR_FORMAT(printf
void log_file(FILE *f)
void * log_get_lock(void)
void log_info(const char *format,...) ATTR_FORMAT(printf
verbosity_value
Definition: log.h:49
void void log_vmsg(int pri, const char *type, const char *format, va_list args)
void log_set_time_asc(int use_asc)
const char * buf
Definition: slow_memmem.cpp:74
Definition: log.h:59
void fatal_exit(const char *format,...) ATTR_FORMAT(printf
void void void log_warn(const char *format,...) ATTR_FORMAT(printf
void log_set_time(time_t *t)
void log_buf(enum verbosity_value level, const char *msg, struct sldns_buffer *buf)
void void void void log_hex(const char *msg, void *data, size_t length)
void verbose(enum verbosity_value level, const char *format,...) ATTR_FORMAT(printf