libcoap  4.0.3
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
debug.h
Go to the documentation of this file.
1 /* debug.h -- debug utilities
2  *
3  * Copyright (C) 2010,2011 Olaf Bergmann <bergmann@tzi.org>
4  *
5  * This file is part of the CoAP library libcoap. Please see
6  * README for terms of use.
7  */
8 
9 #ifndef _COAP_DEBUG_H_
10 #define _COAP_DEBUG_H_
11 
12 #include "config.h"
13 
14 #ifndef COAP_DEBUG_FD
15 #define COAP_DEBUG_FD stdout
16 #endif
17 
18 #ifndef COAP_ERR_FD
19 #define COAP_ERR_FD stderr
20 #endif
21 
23 typedef enum { LOG_EMERG=0, LOG_ALERT, LOG_CRIT, LOG_WARN,
25 } coap_log_t;
26 
29 
31 void coap_set_log_level(coap_log_t level);
32 
39 void coap_log_impl(coap_log_t level, const char *format, ...);
40 
41 #ifndef coap_log
42 #define coap_log(...) coap_log_impl(__VA_ARGS__)
43 #endif
44 
45 #ifndef NDEBUG
46 
47 /* A set of convenience macros for common log levels. */
48 #define info(...) coap_log(LOG_INFO, __VA_ARGS__)
49 #define warn(...) coap_log(LOG_WARN, __VA_ARGS__)
50 #define debug(...) coap_log(LOG_DEBUG, __VA_ARGS__)
51 
52 #include "pdu.h"
53 void coap_show_pdu(const coap_pdu_t *);
54 
55 struct __coap_address_t;
56 size_t coap_print_addr(const struct __coap_address_t *, unsigned char *, size_t);
57 
58 #else
59 
60 #define debug(...)
61 #define info(...)
62 #define warn(...)
63 
64 #define coap_show_pdu(x)
65 #define coap_print_addr(...)
66 
67 #endif
68 
69 #endif /* _COAP_DEBUG_H_ */