37#define COAP_DEBUG_FD stdout
44#define COAP_ERR_FD stderr
47#ifndef COAP_MAX_LOGGING_LEVEL
48#define COAP_MAX_LOGGING_LEVEL 8
67#define COAP_LOG_CIPHERS COAP_LOG_DTLS_BASE
74#define _COAP_LOG_EMERG 0
75#define _COAP_LOG_ALERT 1
76#define _COAP_LOG_CRIT 2
77#define _COAP_LOG_ERR 3
78#define _COAP_LOG_WARN 4
79#define _COAP_LOG_NOTICE 5
80#define _COAP_LOG_INFO 6
81#define _COAP_LOG_DEBUG 7
82#define _COAP_LOG_OSCORE 8
87#define coap_log_emerg(...) coap_log(COAP_LOG_EMERG, __VA_ARGS__)
89#if (COAP_MAX_LOGGING_LEVEL >= _COAP_LOG_ALERT)
90#define coap_log_alert(...) coap_log(COAP_LOG_ALERT, __VA_ARGS__)
92#define coap_log_alert(...) coap_no_log()
95#if (COAP_MAX_LOGGING_LEVEL >= _COAP_LOG_CRIT)
96#define coap_log_crit(...) coap_log(COAP_LOG_CRIT, __VA_ARGS__)
98#define coap_log_crit(...) coap_no_log()
101#if (COAP_MAX_LOGGING_LEVEL >= _COAP_LOG_ERR)
102#define coap_log_err(...) coap_log(COAP_LOG_ERR, __VA_ARGS__)
104#define coap_log_err(...) coap_no_log()
107#if (COAP_MAX_LOGGING_LEVEL >= _COAP_LOG_WARN)
108#define coap_log_warn(...) coap_log(COAP_LOG_WARN, __VA_ARGS__)
110#define coap_log_warn(...) coap_no_log()
113#if (COAP_MAX_LOGGING_LEVEL >= _COAP_LOG_INFO)
114#define coap_log_info(...) coap_log(COAP_LOG_INFO, __VA_ARGS__)
116#define coap_log_info(...) coap_no_log()
119#if (COAP_MAX_LOGGING_LEVEL >= _COAP_LOG_NOTICE)
120#define coap_log_notice(...) coap_log(COAP_LOG_NOTICE, __VA_ARGS__)
122#define coap_log_notice(...) coap_no_log()
125#if (COAP_MAX_LOGGING_LEVEL >= _COAP_LOG_DEBUG)
126#define coap_log_debug(...) coap_log(COAP_LOG_DEBUG, __VA_ARGS__)
128#define coap_log_debug(...) coap_no_log()
131#if (COAP_MAX_LOGGING_LEVEL >= _COAP_LOG_OSCORE)
132#define coap_log_oscore(...) coap_log(COAP_LOG_OSCORE, __VA_ARGS__)
134#define coap_log_oscore(...) coap_no_log()
146#if !defined(RIOT_VERSION) && !defined(WITH_LWIP) && !defined(WITH_CONTIKI)
148# define LOG_EMERG COAP_LOG_EMERG
151# define LOG_ALERT COAP_LOG_ALERT
154# define LOG_CRIT COAP_LOG_CRIT
157# define LOG_ERR COAP_LOG_ERR
160# define LOG_WARNING COAP_LOG_WARN
163# define LOG_NOTICE COAP_LOG_NOTICE
166# define LOG_INFO COAP_LOG_INFO
169# define LOG_DEBUG COAP_LOG_DEBUG
257#if (defined(__GNUC__))
259 const char *format, ...) __attribute__((format(printf, 2, 3)));
268#ifndef LOG_CONF_LEVEL_COAP
269#define LOG_CONF_LEVEL_COAP 0
272void coap_print_contiki_prefix(
coap_log_t level);
274#define coap_log(level, ...) do { \
275 if (LOG_CONF_LEVEL_COAP && \
276 ((int)((level)) <= (int)coap_get_log_level())) { \
277 coap_print_contiki_prefix(level); \
278 printf(__VA_ARGS__); \
290#define coap_log(level, ...) do { \
291 if ((level) < (coap_get_log_level() + 1)) \
292 coap_log_impl((level), __VA_ARGS__); \
306#define coap_dtls_log(level, ...) do { \
307 if ((int)((level))<=(int)coap_dtls_get_log_level()) \
308 coap_log_impl((level)+COAP_LOG_DTLS_BASE, __VA_ARGS__); \
379 unsigned char *buffer,
size_t size);
392 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.