1COAP_LOGGING(3)                 libcoap Manual                 COAP_LOGGING(3)
2
3
4

NAME

6       coap_logging, coap_log, coap_get_log_level, coap_set_log_level,
7       coap_set_log_handler, coap_package_name, coap_package_version,
8       coap_set_show_pdu_output, coap_show_pdu - Work with CoAP logging
9

SYNOPSIS

11       #include <coap3/coap.h>
12
13       void coap_log(coap_log_t level, const char *format, ...);
14
15       void coap_set_log_level(coap_log_t level);
16
17       coap_log_t coap_get_log_level(void);
18
19       void coap_dtls_set_log_level(int level);
20
21       int coap_dtls_get_log_level(void);
22
23       void coap_set_log_handler(coap_log_handler_t handler);
24
25       const char *coap_package_name(void);
26
27       const char *coap_package_version(void);
28
29       void coap_set_show_pdu_output(int use_fprintf);
30
31       void coap_show_pdu(coap_log_t level, const coap_pdu_t *pdu);
32
33       const char *coap_endpoint_str(const coap_endpoint_t *endpoint);
34
35       const char *coap_session_str(const coap_session_t *session);
36
37       For specific (D)TLS library support, link with -lcoap-3-notls,
38       -lcoap-3-gnutls, -lcoap-3-openssl, -lcoap-3-mbedtls or
39       -lcoap-3-tinydtls. Otherwise, link with -lcoap-3 to get the default
40       (D)TLS library support.
41

DESCRIPTION

43       The logging sub-system supports logging at different levels, and
44       depending on the selected logging level, outputs the appropriate
45       information.
46
47       Logging by default is to stderr or stdout depending on the logging
48       level of the log entry. It ia possible to send the logging information
49       to an application logging callback handler for processing by the
50       application.
51
52       The coap_log() function is used to log information at the appropriate
53       level. The rest of the parameters follow the standard printf() function
54       format.
55
56       Logging levels (coap_log_t) are defined by (the same as for syslog()),
57       which are numerically incrementing in value:
58
59       LOG_EMERG
60           Emergency level (0).
61
62       LOG_ALERT
63           Alert level (1).
64
65       LOG_CRIT
66           Critical level (2).
67
68       LOG_ERR
69           Error level (3).
70
71       LOG_WARNING
72           Warning level (the default) (4).
73
74       LOG_NOTICE
75           Notice level (5).
76
77       LOG_INFO
78           Information level (6).
79
80       LOG_DEBUG
81           Debug level (7).
82
83       The coap_set_log_level() function is used to set the current logging
84       level for output by any subsequent coap_log() calls. Output is only
85       logged if the coap_log() level definition is smaller than or equal to
86       the current logging level.
87
88       The coap_get_log_level() function is used to get the current logging
89       level.
90
91       The coap_dtls_set_log_level() function is used to set the logging level
92       for output by the DTLS library for specific DTLS information. Usually,
93       both coap_set_log_level() and coap_dtls_set_log_level() would be set to
94       the same level value. If the logging level is set to greater than
95       LOG_DEBUG, the underlying TLS library may get more verbose in its
96       output.
97
98       The coap_dtls_get_log_level() function is used to get the current
99       logging level for the DTLS library.
100
101       The coap_set_log_handler()* function can be used to define an
102       alternative logging handler for processing the logging messages. The
103       logging handler prototype is defined as:
104
105           typedef void (*coap_log_handler_t) (coap_log_t level, const char *message);
106
107       The coap_package_name() function returns the name of this library.
108
109       The coap_package_version() function returns the version of this
110       library.
111
112       The coap_set_show_pdu_output() function defines whether the output from
113       coap_show_pdu() is to be either sent to stdout/stderr, or output using
114       coap_log(). use_fprintf is set to 1 for stdout/stderr (the default),
115       and use_fprintf is set to 0 for coap_log().
116
117       The coap_show_pdu() function is used to decode the pdu, outputting as
118       appropriate for logging level. Where the output goes is dependent on
119       coap_set_show_pdu_output().
120
121       The coap_endpoint_str() function returns a description string of the
122       endpoint.
123
124       The coap_session_str() function is used to get a string containing the
125       information about the session.
126

RETURN VALUES

128       The coap_package_name() and coap_package_version() return the
129       appropriate zero-terminated character string.
130
131       The coap_get_log_level() function returns the current logging level.
132
133       The coap_dtls_get_log_level() function returns the current logging
134       level for the DTLS library specifics.
135
136       The coap_endpoint_str() function returns a description string of the
137       endpoint.
138
139       The coap_session_str() function returns a description string of the
140       session.
141

SEE ALSO

143       coap_context(3) and coap_session(3)
144

FURTHER INFORMATION

146       See "RFC7252: The Constrained Application Protocol (CoAP)" for further
147       information.
148

BUGS

150       Please report bugs on the mailing list for libcoap:
151       libcoap-developers@lists.sourceforge.net or raise an issue on GitHub at
152       https://github.com/obgm/libcoap/issues
153

AUTHORS

155       The libcoap project <libcoap-developers@lists.sourceforge.net>
156
157
158
159coap_logging 4.3.0                07/22/2021                   COAP_LOGGING(3)
Impressum