1COAP_LOGGING(3) libcoap Manual COAP_LOGGING(3)
2
3
4
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
11 #include <coap2/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 Link with -lcoap-2, -lcoap-2-gnutls, -lcoap-2-openssl or
38 -lcoap-2-tinydtls depending on your (D)TLS library type.
39
41 The logging sub-system supports logging at different levels, and
42 depending on the selected logging level, outputs the appropriate
43 information.
44
45 Logging by default is to stderr or stdout depending on the logging
46 level of the log entry. It ia possible to send the logging information
47 to an application logging call-back handler for processing by the
48 application.
49
50 The coap_log() function is used to log information at the appropriate
51 level. The rest of the parameters follow the standard printf() function
52 format.
53
54 Logging levels (coap_log_t) are defined by (the same as for syslog()),
55 which are numerically incrementing in value:
56
57 LOG_EMERG
58 Emergency level (0).
59
60 LOG_ALERT
61 Alert level (1).
62
63 LOG_CRIT
64 Critical level (2).
65
66 LOG_ERR
67 Error level (3).
68
69 LOG_WARNING
70 Warning level (the default) (4).
71
72 LOG_NOTICE
73 Notice level (5).
74
75 LOG_INFO
76 Information level (6).
77
78 LOG_DEBUG
79 Debug level (7).
80
81 The coap_set_log_level() function is used to set the current logging
82 level for output by any subsequent coap_log() calls. Output is only
83 logged if the coap_log() level definition is smaller than or equal to
84 the curent logging level.
85
86 The coap_get_log_level() function is used to get the current logging
87 level.
88
89 The coap_dtls_set_log_level() function is used to set the logging level
90 for output by the DTLS library for specific DTLS information. Usually,
91 both coap_set_log_level() and coap_dtls_set_log_level() would be set to
92 the same level value. If the logging level is set to greater than
93 LOG_DEBUG, the underlying TLS library may get more verbose in its
94 output.
95
96 The coap_dtls_get_log_level() function is used to get the current
97 logging level for the DTLS library.
98
99 The coap_set_log_handler()* function can be used to define an
100 alternative logging handler for processing the logging messages. The
101 logging handler prototype is defined as:
102
103 typedef void (*coap_log_handler_t) (coap_log_t level, const char *message);
104
105 The coap_package_name() function returns the name of this library.
106
107 The coap_package_version() function returns the version of this
108 library.
109
110 The coap_set_show_pdu_output() function defines whether the output from
111 coap_show_pdu() is to be either sent to stdout/stderr, or output using
112 coap_log(). use_fprintf is set to 1 for stdout/stderr (the default),
113 and use_fprintf is set to 0 for coap_log().
114
115 The coap_show_pdu() function is used to decode the pdu, outputting as
116 appropriate for logging level. Where the output goes is dependent on
117 coap_set_show_pdu_output().
118
119 The coap_endpoint_str() function returns a description string of the
120 endpoint.
121
122 The coap_session_str() function is used to get a string containing the
123 information about the session.
124
126 The coap_package_name() and coap_package_version() return the
127 appropriate zero-terminated character string.
128
129 The coap_get_log_level() function returns the current logging level.
130
131 The coap_dtls_get_log_level() function returns the current logging
132 level for the DTLS library specifics.
133
134 The coap_endpoint_str() function returns a description string of the
135 endpoint.
136
137 The coap_session_str() function returns a description string of the
138 session.
139
141 coap_context(3) and coap_session(3)
142
144 See "RFC7252: The Constrained Application Protocol (CoAP)" for further
145 information.
146
148 Please report bugs on the mailing list for libcoap:
149 libcoap-developers@lists.sourceforge.net
150
152 The libcoap project <libcoap-developers@lists.sourceforge.net>
153
154
155
156coap_logging 4.2.0 07/25/2019 COAP_LOGGING(3)