31#define COAP_DEBUG_FD stdout
38#define COAP_ERR_FD stderr
41#ifndef COAP_MAX_LOGGING_LEVEL
42#define COAP_MAX_LOGGING_LEVEL 8
61#define COAP_LOG_CIPHERS COAP_LOG_DTLS_BASE
68#define _COAP_LOG_EMERG 0
69#define _COAP_LOG_ALERT 1
70#define _COAP_LOG_CRIT 2
71#define _COAP_LOG_ERR 3
72#define _COAP_LOG_WARN 4
73#define _COAP_LOG_NOTICE 5
74#define _COAP_LOG_INFO 6
75#define _COAP_LOG_DEBUG 7
76#define _COAP_LOG_OSCORE 8
81#define coap_log_emerg(...) coap_log(COAP_LOG_EMERG, __VA_ARGS__)
83#if (COAP_MAX_LOGGING_LEVEL >= _COAP_LOG_ALERT)
84#define coap_log_alert(...) coap_log(COAP_LOG_ALERT, __VA_ARGS__)
86#define coap_log_alert(...) coap_no_log()
89#if (COAP_MAX_LOGGING_LEVEL >= _COAP_LOG_CRIT)
90#define coap_log_crit(...) coap_log(COAP_LOG_CRIT, __VA_ARGS__)
92#define coap_log_crit(...) coap_no_log()
95#if (COAP_MAX_LOGGING_LEVEL >= _COAP_LOG_ERR)
96#define coap_log_err(...) coap_log(COAP_LOG_ERR, __VA_ARGS__)
98#define coap_log_err(...) coap_no_log()
101#if (COAP_MAX_LOGGING_LEVEL >= _COAP_LOG_WARN)
102#define coap_log_warn(...) coap_log(COAP_LOG_WARN, __VA_ARGS__)
104#define coap_log_warn(...) coap_no_log()
107#if (COAP_MAX_LOGGING_LEVEL >= _COAP_LOG_INFO)
108#define coap_log_info(...) coap_log(COAP_LOG_INFO, __VA_ARGS__)
110#define coap_log_info(...) coap_no_log()
113#if (COAP_MAX_LOGGING_LEVEL >= _COAP_LOG_NOTICE)
114#define coap_log_notice(...) coap_log(COAP_LOG_NOTICE, __VA_ARGS__)
116#define coap_log_notice(...) coap_no_log()
119#if (COAP_MAX_LOGGING_LEVEL >= _COAP_LOG_DEBUG)
120#define coap_log_debug(...) coap_log(COAP_LOG_DEBUG, __VA_ARGS__)
122#define coap_log_debug(...) coap_no_log()
125#if (COAP_MAX_LOGGING_LEVEL >= _COAP_LOG_OSCORE)
126#define coap_log_oscore(...) coap_log(COAP_LOG_OSCORE, __VA_ARGS__)
128#define coap_log_oscore(...) coap_no_log()
140#if !defined(RIOT_VERSION) && !defined(WITH_LWIP) && !defined(WITH_CONTIKI)
142# define LOG_EMERG COAP_LOG_EMERG
145# define LOG_ALERT COAP_LOG_ALERT
148# define LOG_CRIT COAP_LOG_CRIT
151# define LOG_ERR COAP_LOG_ERR
154# define LOG_WARNING COAP_LOG_WARN
157# define LOG_NOTICE COAP_LOG_NOTICE
160# define LOG_INFO COAP_LOG_INFO
163# define LOG_DEBUG COAP_LOG_DEBUG
251#if (defined(__GNUC__))
253 const char *format, ...) __attribute__((format(printf, 2, 3)));
262#ifndef LOG_CONF_LEVEL_COAP
263#define LOG_CONF_LEVEL_COAP 0
266void coap_print_contiki_prefix(
coap_log_t level);
268#define coap_log(level, ...) do { \
269 if (LOG_CONF_LEVEL_COAP && \
270 ((int)((level)) <= (int)coap_get_log_level())) { \
271 coap_print_contiki_prefix(level); \
272 printf(__VA_ARGS__); \
284#define coap_log(level, ...) do { \
285 if ((level) < (coap_get_log_level() + 1)) \
286 coap_log_impl((level), __VA_ARGS__); \
300#define coap_dtls_log(level, ...) do { \
301 if ((int)((level))<=(int)coap_dtls_get_log_level()) \
302 coap_log_impl((level)+COAP_LOG_DTLS_BASE, __VA_ARGS__); \
375 unsigned char *buffer,
size_t size);
388 char *buffer,
size_t size);
int coap_debug_set_packet_loss(const char *loss_level)
Set the packet loss level for testing.
Pre-defined constants that reflect defaults for CoAP.
void coap_set_log_handler(coap_log_handler_t handler)
Add a custom log callback handler.
const char * coap_log_level_desc(coap_log_t level)
Get the current logging description.
coap_log_t coap_get_log_level(void)
Get the current logging level.
char * coap_string_tls_version(char *buffer, size_t bufsize)
Build a string containing the current (D)TLS library linked with and built for version.
void coap_show_pdu(coap_log_t level, const coap_pdu_t *pdu)
Display the contents of the specified pdu.
void coap_enable_pdu_data_output(int enable_data)
Defines whether the data is to be output or not for the coap_show_pdu() function.
char * coap_string_tls_support(char *buffer, size_t bufsize)
Build a string containing the current (D)TLS library support.
coap_log_t coap_dtls_get_log_level(void)
Get the current (D)TLS logging.
const char * coap_package_version(void)
Get the library package version.
void coap_set_log_level(coap_log_t level)
Sets the log level to the specified value.
void coap_dtls_set_log_level(coap_log_t level)
Sets the (D)TLS logging level to the specified level.
void coap_log_impl(coap_log_t level, const char *format,...)
Writes the given text to COAP_ERR_FD (for level <= COAP_LOG_CRIT) or COAP_DEBUG_FD (for level >= COAP...
size_t coap_print_addr(const coap_address_t *address, unsigned char *buffer, size_t size)
Print the address into the defined buffer.
const char * coap_package_build(void)
Get the library package build.
const char * coap_print_ip_addr(const coap_address_t *address, char *buffer, size_t size)
Print the IP address into the defined buffer.
void coap_show_tls_version(coap_log_t level)
Display the current (D)TLS library linked with and built for version.
void coap_set_show_pdu_output(int use_fprintf)
Defines the output mode for the coap_show_pdu() function.
COAP_STATIC_INLINE void coap_no_log(void)
const char * coap_package_name(void)
Get the library package name.
void(* coap_log_handler_t)(coap_log_t level, const char *message)
Logging callback handler definition.
#define COAP_STATIC_INLINE
Multi-purpose address abstraction.