libcoap 4.3.5-develop-19cef11
|
API for logging support. 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... | |
const char * | coap_session_str (const coap_session_t *session) |
Get session description. More... | |
const char * | coap_endpoint_str (const coap_endpoint_t *endpoint) |
Get endpoint description. More... | |
API for logging support.
#define _COAP_LOG_ALERT 1 |
Definition at line 69 of file coap_debug.h.
#define _COAP_LOG_CRIT 2 |
Definition at line 70 of file coap_debug.h.
#define _COAP_LOG_DEBUG 7 |
Definition at line 75 of file coap_debug.h.
#define _COAP_LOG_EMERG 0 |
Definition at line 68 of file coap_debug.h.
#define _COAP_LOG_ERR 3 |
Definition at line 71 of file coap_debug.h.
#define _COAP_LOG_INFO 6 |
Definition at line 74 of file coap_debug.h.
#define _COAP_LOG_NOTICE 5 |
Definition at line 73 of file coap_debug.h.
#define _COAP_LOG_OSCORE 8 |
Definition at line 76 of file coap_debug.h.
#define _COAP_LOG_WARN 4 |
Definition at line 72 of file coap_debug.h.
#define COAP_DEBUG_FD stdout |
Used for output for COAP_LOG_OSCORE
to COAP_LOG_ERR
.
Definition at line 31 of file coap_debug.h.
#define coap_dtls_log | ( | level, | |
... | |||
) |
Logging function.
Writes the given text to COAP_ERR_FD
(for level
<= COAP_LOG_CRIT
) or COAP_DEBUG_FD
(for level
>= COAP_LOG_ERR
). The text is output only when level
is below or equal to the log level that set by coap_dtls_set_log_level().
level | One of the COAP_LOG_* values. |
Definition at line 300 of file coap_debug.h.
#define COAP_ERR_FD stderr |
Used for output for COAP_LOG_CRIT
to COAP_LOG_EMERG
.
Definition at line 38 of file coap_debug.h.
#define coap_log | ( | level, | |
... | |||
) |
Logging function.
Writes the given text to COAP_ERR_FD
(for level
<= COAP_LOG_CRIT
) or COAP_DEBUG_FD
(for level
>= COAP_LOG_ERR
). The text is output only when level
is below or equal to the log level that set by coap_set_log_level().
level | One of the COAP_LOG_* values. |
Definition at line 284 of file coap_debug.h.
#define coap_log_alert | ( | ... | ) | coap_log(COAP_LOG_ALERT, __VA_ARGS__) |
Definition at line 84 of file coap_debug.h.
#define coap_log_crit | ( | ... | ) | coap_log(COAP_LOG_CRIT, __VA_ARGS__) |
Definition at line 90 of file coap_debug.h.
#define coap_log_debug | ( | ... | ) | coap_log(COAP_LOG_DEBUG, __VA_ARGS__) |
Definition at line 120 of file coap_debug.h.
#define coap_log_emerg | ( | ... | ) | coap_log(COAP_LOG_EMERG, __VA_ARGS__) |
Definition at line 81 of file coap_debug.h.
#define coap_log_err | ( | ... | ) | coap_log(COAP_LOG_ERR, __VA_ARGS__) |
Definition at line 96 of file coap_debug.h.
#define coap_log_info | ( | ... | ) | coap_log(COAP_LOG_INFO, __VA_ARGS__) |
Definition at line 108 of file coap_debug.h.
#define coap_log_notice | ( | ... | ) | coap_log(COAP_LOG_NOTICE, __VA_ARGS__) |
Definition at line 114 of file coap_debug.h.
#define coap_log_oscore | ( | ... | ) | coap_log(COAP_LOG_OSCORE, __VA_ARGS__) |
Definition at line 126 of file coap_debug.h.
#define coap_log_warn | ( | ... | ) | coap_log(COAP_LOG_WARN, __VA_ARGS__) |
Definition at line 102 of file coap_debug.h.
#define COAP_MAX_LOGGING_LEVEL 8 |
Definition at line 42 of file coap_debug.h.
#define LOG_ALERT COAP_LOG_ALERT |
Definition at line 145 of file coap_debug.h.
#define LOG_CRIT COAP_LOG_CRIT |
Definition at line 148 of file coap_debug.h.
#define LOG_DEBUG COAP_LOG_DEBUG |
Definition at line 163 of file coap_debug.h.
#define LOG_EMERG COAP_LOG_EMERG |
Definition at line 142 of file coap_debug.h.
#define LOG_ERR COAP_LOG_ERR |
Definition at line 151 of file coap_debug.h.
#define LOG_INFO COAP_LOG_INFO |
Definition at line 160 of file coap_debug.h.
#define LOG_NOTICE COAP_LOG_NOTICE |
Definition at line 157 of file coap_debug.h.
#define LOG_WARNING COAP_LOG_WARN |
Definition at line 154 of file coap_debug.h.
typedef void(* coap_log_handler_t) (coap_log_t level, const char *message) |
Logging callback handler definition.
level | One of the COAP_LOG_* values, or if used for (D)TLS logging, COAP_LOG_DTLS_BASE + one of the COAP_LOG_* values. |
message | Zero-terminated string message to log. |
Definition at line 209 of file coap_debug.h.
enum coap_log_t |
Logging type.
These should be used where possible in the code instead of the syslog definitions, or alternatively use the coap_log_*() functions to reduce line length.
Enumerator | |
---|---|
COAP_LOG_EMERG | |
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 |
Definition at line 50 of file coap_debug.h.
coap_log_t coap_dtls_get_log_level | ( | void | ) |
Get the current (D)TLS logging.
Definition at line 171 of file coap_notls.c.
void coap_dtls_set_log_level | ( | coap_log_t | level | ) |
Sets the (D)TLS logging level to the specified level
.
level | One of the COAP_LOG_* values. |
Definition at line 166 of file coap_notls.c.
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.
enable_data | 1 if the data is to be output (the default) 0 if the data detail is not to be output. |
Definition at line 96 of file coap_debug.c.
const char * coap_endpoint_str | ( | const coap_endpoint_t * | endpoint | ) |
Get endpoint description.
endpoint | The CoAP endpoint. |
coap_log_t coap_get_log_level | ( | void | ) |
Get the current logging level.
Definition at line 101 of file coap_debug.c.
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
).
The text is output only when level
is below or equal to the log level that set by coap_set_log_level().
Internal function.
level | One of the COAP_LOG_* values. & |
format | The format string to use. |
Definition at line 1282 of file coap_debug.c.
const char * coap_log_level_desc | ( | coap_log_t | level | ) |
Get the current logging description.
Definition at line 122 of file coap_debug.c.
COAP_STATIC_INLINE void coap_no_log | ( | void | ) |
Definition at line 79 of file coap_debug.h.
const char * coap_package_build | ( | void | ) |
Get the library package build.
Definition at line 82 of file coap_debug.c.
const char * coap_package_name | ( | void | ) |
Get the library package name.
Definition at line 72 of file coap_debug.c.
const char * coap_package_version | ( | void | ) |
Get the library package version.
Definition at line 77 of file coap_debug.c.
size_t coap_print_addr | ( | const coap_address_t * | address, |
unsigned char * | buffer, | ||
size_t | size | ||
) |
Print the address into the defined buffer.
address | The address to print. |
buffer | The buffer to print into. |
size | The size of the buffer to print into. |
Definition at line 239 of file coap_debug.c.
const char * coap_print_ip_addr | ( | const coap_address_t * | address, |
char * | buffer, | ||
size_t | size | ||
) |
Print the IP address into the defined buffer.
address | The address to print. |
buffer | The buffer to print into. |
size | The size of the buffer to print into. |
Definition at line 415 of file coap_debug.c.
const char * coap_session_str | ( | const coap_session_t * | session | ) |
Get session description.
session | The CoAP session. |
Definition at line 2258 of file coap_session.c.
void coap_set_log_handler | ( | coap_log_handler_t | handler | ) |
Add a custom log callback handler.
handler | The logging handler to use or NULL to use default handler. This handler will be used for both CoAP and (D)TLS logging. |
Definition at line 1277 of file coap_debug.c.
void coap_set_log_level | ( | coap_log_t | level | ) |
Sets the log level to the specified value.
level | One of the COAP_LOG_* values. |
Definition at line 106 of file coap_debug.c.
void coap_set_show_pdu_output | ( | int | use_fprintf | ) |
Defines the output mode for the coap_show_pdu() function.
use_fprintf | 1 if the output is to use fprintf() (the default) 0 if the output is to use coap_log(). |
Definition at line 91 of file coap_debug.c.
void coap_show_pdu | ( | coap_log_t | level, |
const coap_pdu_t * | pdu | ||
) |
Display the contents of the specified pdu
.
Note: The output method of coap_show_pdu() is dependent on the setting of coap_set_show_pdu_output(). Note: Data may, or may not be output depending on the setting of coap_enable_pdu_data_output().
level | The required minimum logging level. |
pdu | The PDU to decode. |
Definition at line 784 of file coap_debug.c.
void coap_show_tls_version | ( | coap_log_t | level | ) |
Display the current (D)TLS library linked with and built for version.
level | The required minimum logging level. |
Definition at line 1136 of file coap_debug.c.
char * coap_string_tls_support | ( | char * | buffer, |
size_t | bufsize | ||
) |
Build a string containing the current (D)TLS library support.
buffer | The buffer to put the string into. |
bufsize | The size of the buffer to put the string into. |
Definition at line 1245 of file coap_debug.c.
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.
buffer | The buffer to put the string into. |
bufsize | The size of the buffer to put the string into. |
Definition at line 1143 of file coap_debug.c.