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

NAME

6       coap_logging, coap_log, coap_log_emerg, coap_log_alert, coap_log_crit,
7       coap_log_err, coap_log_warn, coap_log_info, coap_log_notice,
8       coap_log_debug, coap_log_oscore, coap_get_log_level,
9       coap_set_log_level, coap_dtls_log, coap_dtls_get_log_level,
10       coap_dtls_set_log_level, coap_set_log_handler, coap_package_name,
11       coap_package_version, coap_package_build, coap_set_show_pdu_output,
12       coap_show_pdu, coap_endpoint_str, coap_session_str, coap_print_addr,
13       coap_print_ip_addr - Work with CoAP logging
14

SYNOPSIS

16       #include <coap3/coap.h>
17
18       void coap_log(coap_log_t level, const char *format, ...);
19
20       void coap_log_emerg(const char *format, ...);
21
22       void coap_log_alert(const char *format, ...);
23
24       void coap_log_crit(const char *format, ...);
25
26       void coap_log_err(const char *format, ...);
27
28       void coap_log_warn(const char *format, ...);
29
30       void coap_log_info(const char *format, ...);
31
32       void coap_log_notice(const char *format, ...);
33
34       void coap_log_debug(const char *format, ...);
35
36       void coap_log_oscore(const char *format, ...);
37
38       void coap_set_log_level(coap_log_t level);
39
40       coap_log_t coap_get_log_level(void);
41
42       void coap_dtls_log(coap_log_t level, const char *format, ...);
43
44       void coap_dtls_set_log_level(coap_log_t level);
45
46       coap_log_t coap_dtls_get_log_level(void);
47
48       void coap_set_log_handler(coap_log_handler_t handler);
49
50       const char *coap_package_name(void);
51
52       const char *coap_package_version(void);
53
54       const char *coap_package_build(void);
55
56       void coap_set_show_pdu_output(int use_fprintf);
57
58       void coap_show_pdu(coap_log_t level, const coap_pdu_t *pdu);
59
60       const char *coap_endpoint_str(const coap_endpoint_t *endpoint);
61
62       const char *coap_session_str(const coap_session_t *session);
63
64       size_t coap_print_addr(const coap_address_t *address, unsigned char
65       *buffer, size_t length);
66
67       const char *coap_print_ip_addr(const coap_address_t *address, char
68       *buffer, size_t length);
69
70       For specific (D)TLS library support, link with -lcoap-3-notls,
71       -lcoap-3-gnutls, -lcoap-3-openssl, -lcoap-3-mbedtls or
72       -lcoap-3-tinydtls. Otherwise, link with -lcoap-3 to get the default
73       (D)TLS library support.
74

DESCRIPTION

76       The logging sub-system supports logging at different levels, and
77       depending on the selected logging level, outputs the appropriate
78       information.
79
80       Logging by default is to stderr or stdout depending on the logging
81       level of the log entry. It ia possible to send the logging information
82       to an application logging callback handler for processing by the
83       application.
84
85       Logging levels (coap_log_t) are defined as follows (based on the
86       syslog() names and values):
87
88       COAP_LOG_EMERG
89           Emergency level (0).
90
91       COAP_LOG_ALERT
92           Alert level (1).
93
94       COAP_LOG_CRIT
95           Critical level (2).
96
97       COAP_LOG_ERR
98           Error level (3).
99
100       COAP_LOG_WARN
101           Warning level (the default) (4).
102
103       COAP_LOG_NOTICE
104           Notice level (5).
105
106       COAP_LOG_INFO
107           Information level (6).
108
109       COAP_LOG_DEBUG
110           Debug level (7).
111
112       With additional level:
113
114       COAP_LOG_OSCORE
115           Debug OSCORE information (8).
116
117       NOTE: The maximum logging level in the libcoap library may have been
118       updated by the use of ./configure --enable-max-logging-level=X (where X
119       is 0 to 8 inclusive) which may disable some of the higher logging
120       levels to save code space.
121

FUNCTIONS

123       Function: coap_log()
124
125       The coap_log() function is used to log information at the appropriate
126       level. The rest of the parameters follow the standard printf() function
127       format. Where possible, the coap_log_*() functions should be used
128       instead.
129
130       Function: coap_log_emerg()
131
132       The coap_log_emerg() function provides a wrapper to the coap_log()
133       function with level set to COAP_LOG_EMERG. The parameters follow the
134       standard printf() function format.
135
136       Function: coap_log_alert()
137
138       The coap_log_alert() function provides a wrapper to the coap_log()
139       function with level set to COAP_LOG_ALERT. The parameters follow the
140       standard printf() function format.
141
142       Function: coap_log_crit()
143
144       The coap_log_crit() function provides a wrapper to the coap_log()
145       function with level set to COAP_LOG_CRIT. The parameters follow the
146       standard printf() function format.
147
148       Function: coap_log_err()
149
150       The coap_log_err() function provides a wrapper to the coap_log()
151       function with level set to COAP_LOG_ERR. The parameters follow the
152       standard printf() function format.
153
154       Function: coap_log_warn()
155
156       The coap_log_warn() function provides a wrapper to the coap_log()
157       function with level set to COAP_LOG_WARN. The parameters follow the
158       standard printf() function format.
159
160       Function: coap_log_notice()
161
162       The coap_log_notice() function provides a wrapper to the coap_log()
163       function with level set to COAP_LOG_NOTICE. The parameters follow the
164       standard printf() function format.
165
166       Function: coap_log_info()
167
168       The coap_log_info() function provides a wrapper to the coap_log()
169       function with level set to COAP_LOG_INFO. The parameters follow the
170       standard printf() function format.
171
172       Function: coap_log_debug()
173
174       The coap_log_debug() function provides a wrapper to the coap_log()
175       function with level set to COAP_LOG_DEBUG. The parameters follow the
176       standard printf() function format.
177
178       Function: coap_log_oscore()
179
180       The coap_log_oscore() function provides a wrapper to the coap_log()
181       function with level set to COAP_LOG_OSCORE. The parameters follow the
182       standard printf() function format.
183
184       Function: coap_set_log_level()
185
186       The coap_set_log_level() function is used to set the current logging
187       level for output by any subsequent coap_log() calls. Output is only
188       logged if the coap_log() level definition is smaller than or equal to
189       the current logging level.
190
191       Function: coap_get_log_level()
192
193       The coap_get_log_level() function is used to get the current logging
194       level.
195
196       Function: coap_dtls_log()
197
198       The coap_dtls_log() function is used to log (D)TLS library information
199       at the appropriate level. The rest of the parameters follow the
200       standard printf() function format.
201
202       Function: coap_dtls_set_log_level()
203
204       The coap_dtls_set_log_level() function is used to set the current
205       logging level for output by any subsequent coap_dtls_log() calls.
206       Output is only logged if the coap_dtls_log() level definition is
207       smaller than or equal to the current DTLS logging level.
208
209       Function: coap_dtls_get_log_level()
210
211       The coap_dtls_get_log_level() function is used to get the current
212       logging level for the DTLS library.
213
214       Function: coap_set_log_handler()
215
216       The coap_set_log_handler()* function can be used to define an
217       alternative logging handler for processing any logging messages. The
218       logging handler prototype is defined as:
219
220           typedef void (*coap_log_handler_t) (coap_log_t level, const char *message);
221
222       Function: coap_package_name()
223
224       The coap_package_name() function returns the name of this library.
225
226       Function: coap_package_version()
227
228       The coap_package_version() function returns the version of this
229       library.
230
231       Function: coap_package_build()
232
233       The coap_package_build() function returns the git information (as in
234       "git describe --tags") for the build of this library or version of this
235       library if git is not used.
236
237       Function: coap_set_show_pdu_output()
238
239       The coap_set_show_pdu_output() function defines whether the output from
240       coap_show_pdu() is to be either sent to stdout/stderr, or output using
241       coap_log(). use_fprintf is set to 1 for stdout/stderr (the default),
242       and use_fprintf is set to 0 for coap_log().
243
244       Function: coap_show_pdu()
245
246       The coap_show_pdu() function is used to decode the pdu, outputting as
247       appropriate for logging level. Where the output goes is dependent on
248       coap_set_show_pdu_output().
249
250       NOTE: If pdu has not been associated with a CoAP session (i.e. not a
251       received PDU or coap_send() not yet called), then the output assumes
252       that this pdu is of type unreliable.
253
254       Function: coap_endpoint_str()
255
256       The coap_endpoint_str() function returns a description string of the
257       endpoint.
258
259       Function: coap_session_str()
260
261       The coap_session_str() function is used to get a string containing the
262       information about the session.
263
264       Function: coap_print_addr()
265
266       The coap_print_addr() function returns the length of the description
267       string containing the IP address and port from address, updating buffer
268       which has a maximum length length.
269
270       Function: coap_print_ip_addr()
271
272       The coap_print_ip_addr() function returns a description string of the
273       IP address only for address. buffer is updated, which has a maximum
274       length of length.
275

RETURN VALUES

277       coap_package_name(), coap_package_version() and coap_package_build()
278       return the appropriate zero-terminated character string.
279
280       coap_get_log_level() returns the current logging level.
281
282       coap_dtls_get_log_level() returns the current logging level for the
283       DTLS library specifics.
284
285       coap_endpoint_str() returns a description string of the endpoint.
286
287       coap_session_str() returns a description string of the session.
288
289       coap_print_addr() returns the length of buffer that has been updated
290       with an ascii readable IP address and port for address.
291
292       coap_print_ip_addr() returns a pointer to the ascii readable IP address
293       only for address.
294

SEE ALSO

296       coap_context(3) and coap_session(3)
297

FURTHER INFORMATION

299       See
300
301       "RFC7252: The Constrained Application Protocol (CoAP)"
302
303       for further information.
304

BUGS

306       Please report bugs on the mailing list for libcoap:
307       libcoap-developers@lists.sourceforge.net or raise an issue on GitHub at
308       https://github.com/obgm/libcoap/issues
309

AUTHORS

311       The libcoap project <libcoap-developers@lists.sourceforge.net>
312
313
314
315coap_logging 4.3.4                10/09/2023                   COAP_LOGGING(3)
Impressum