libcoap 4.3.5-develop-19cef11
coap_debug.h File Reference

CoAP Logging support. More...

#include "coap_pdu.h"
+ Include dependency graph for coap_debug.h:
+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define COAP_DEBUG_FD   stdout
 Used for output for COAP_LOG_OSCORE to COAP_LOG_ERR. More...
 
#define COAP_ERR_FD   stderr
 Used for output for COAP_LOG_CRIT to COAP_LOG_EMERG. More...
 
#define COAP_MAX_LOGGING_LEVEL   8
 
#define COAP_LOG_CIPHERS   COAP_LOG_DTLS_BASE /* For backward compatability */
 
#define _COAP_LOG_EMERG   0
 
#define _COAP_LOG_ALERT   1
 
#define _COAP_LOG_CRIT   2
 
#define _COAP_LOG_ERR   3
 
#define _COAP_LOG_WARN   4
 
#define _COAP_LOG_NOTICE   5
 
#define _COAP_LOG_INFO   6
 
#define _COAP_LOG_DEBUG   7
 
#define _COAP_LOG_OSCORE   8
 
#define coap_log_emerg(...)   coap_log(COAP_LOG_EMERG, __VA_ARGS__)
 
#define coap_log_alert(...)   coap_log(COAP_LOG_ALERT, __VA_ARGS__)
 
#define coap_log_crit(...)   coap_log(COAP_LOG_CRIT, __VA_ARGS__)
 
#define coap_log_err(...)   coap_log(COAP_LOG_ERR, __VA_ARGS__)
 
#define coap_log_warn(...)   coap_log(COAP_LOG_WARN, __VA_ARGS__)
 
#define coap_log_info(...)   coap_log(COAP_LOG_INFO, __VA_ARGS__)
 
#define coap_log_notice(...)   coap_log(COAP_LOG_NOTICE, __VA_ARGS__)
 
#define coap_log_debug(...)   coap_log(COAP_LOG_DEBUG, __VA_ARGS__)
 
#define coap_log_oscore(...)   coap_log(COAP_LOG_OSCORE, __VA_ARGS__)
 
#define LOG_EMERG   COAP_LOG_EMERG
 
#define LOG_ALERT   COAP_LOG_ALERT
 
#define LOG_CRIT   COAP_LOG_CRIT
 
#define LOG_ERR   COAP_LOG_ERR
 
#define LOG_WARNING   COAP_LOG_WARN
 
#define LOG_NOTICE   COAP_LOG_NOTICE
 
#define LOG_INFO   COAP_LOG_INFO
 
#define LOG_DEBUG   COAP_LOG_DEBUG
 
#define coap_log(level, ...)
 Logging function. More...
 
#define coap_dtls_log(level, ...)
 Logging function. More...
 

Typedefs

typedef void(* coap_log_handler_t) (coap_log_t level, const char *message)
 Logging callback handler definition. More...
 

Enumerations

enum  coap_log_t {
  COAP_LOG_EMERG = 0 , COAP_LOG_ALERT , COAP_LOG_CRIT , COAP_LOG_ERR ,
  COAP_LOG_WARN , COAP_LOG_NOTICE , COAP_LOG_INFO , COAP_LOG_DEBUG ,
  COAP_LOG_OSCORE , COAP_LOG_DTLS_BASE
}
 Logging type. More...
 

Functions

COAP_STATIC_INLINE void coap_no_log (void)
 
coap_log_t coap_get_log_level (void)
 Get the current logging level. More...
 
void coap_set_log_level (coap_log_t level)
 Sets the log level to the specified value. More...
 
void coap_dtls_set_log_level (coap_log_t level)
 Sets the (D)TLS logging level to the specified level. More...
 
coap_log_t coap_dtls_get_log_level (void)
 Get the current (D)TLS logging. More...
 
const char * coap_log_level_desc (coap_log_t level)
 Get the current logging description. More...
 
void coap_set_log_handler (coap_log_handler_t handler)
 Add a custom log callback handler. More...
 
const char * coap_package_name (void)
 Get the library package name. More...
 
const char * coap_package_version (void)
 Get the library package version. More...
 
const char * coap_package_build (void)
 Get the library package build. More...
 
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_LOG_ERR). More...
 
void coap_set_show_pdu_output (int use_fprintf)
 Defines the output mode for the coap_show_pdu() function. More...
 
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. More...
 
void coap_show_pdu (coap_log_t level, const coap_pdu_t *pdu)
 Display the contents of the specified pdu. More...
 
void coap_show_tls_version (coap_log_t level)
 Display the current (D)TLS library linked with and built for version. More...
 
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. More...
 
char * coap_string_tls_support (char *buffer, size_t bufsize)
 Build a string containing the current (D)TLS library support. More...
 
size_t coap_print_addr (const coap_address_t *address, unsigned char *buffer, size_t size)
 Print the address into the defined buffer. More...
 
const char * coap_print_ip_addr (const coap_address_t *address, char *buffer, size_t size)
 Print the IP address into the defined buffer. More...
 
int coap_debug_set_packet_loss (const char *loss_level)
 Set the packet loss level for testing. More...
 

Detailed Description

CoAP Logging support.

Definition in file coap_debug.h.

Macro Definition Documentation

◆ COAP_LOG_CIPHERS

#define COAP_LOG_CIPHERS   COAP_LOG_DTLS_BASE /* For backward compatability */

Definition at line 61 of file coap_debug.h.

Function Documentation

◆ coap_debug_set_packet_loss()

int coap_debug_set_packet_loss ( const char *  loss_level)

Set the packet loss level for testing.

This can be in one of two forms.

Percentage : 0% to 100%. Use the specified probability. 0% is send all packets, 100% is drop all packets.

List: A comma separated list of numbers or number ranges that are the packets to drop.

Parameters
loss_levelThe defined loss level (percentage or list).
Returns
1 If loss level set, 0 if there is an error.

Definition at line 1337 of file coap_debug.c.