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_package_build, coap_set_show_pdu_output, coap_show_pdu,
9 coap_endpoint_str, coap_session_str - Work with CoAP logging
10
12 #include <coap3/coap.h>
13
14 void coap_log(coap_log_t level, const char *format, ...);
15
16 void coap_set_log_level(coap_log_t level);
17
18 coap_log_t coap_get_log_level(void);
19
20 void coap_dtls_set_log_level(int level);
21
22 int coap_dtls_get_log_level(void);
23
24 void coap_set_log_handler(coap_log_handler_t handler);
25
26 const char *coap_package_name(void);
27
28 const char *coap_package_version(void);
29
30 const char *coap_package_build(void);
31
32 void coap_set_show_pdu_output(int use_fprintf);
33
34 void coap_show_pdu(coap_log_t level, const coap_pdu_t *pdu);
35
36 const char *coap_endpoint_str(const coap_endpoint_t *endpoint);
37
38 const char *coap_session_str(const coap_session_t *session);
39
40 For specific (D)TLS library support, link with -lcoap-3-notls,
41 -lcoap-3-gnutls, -lcoap-3-openssl, -lcoap-3-mbedtls or
42 -lcoap-3-tinydtls. Otherwise, link with -lcoap-3 to get the default
43 (D)TLS library support.
44
46 The logging sub-system supports logging at different levels, and
47 depending on the selected logging level, outputs the appropriate
48 information.
49
50 Logging by default is to stderr or stdout depending on the logging
51 level of the log entry. It ia possible to send the logging information
52 to an application logging callback handler for processing by the
53 application.
54
55 The coap_log() function is used to log information at the appropriate
56 level. The rest of the parameters follow the standard printf() function
57 format.
58
59 Logging levels (coap_log_t) are defined by (the same as for syslog()),
60 which are numerically incrementing in value:
61
62 LOG_EMERG
63 Emergency level (0).
64
65 LOG_ALERT
66 Alert level (1).
67
68 LOG_CRIT
69 Critical level (2).
70
71 LOG_ERR
72 Error level (3).
73
74 LOG_WARNING
75 Warning level (the default) (4).
76
77 LOG_NOTICE
78 Notice level (5).
79
80 LOG_INFO
81 Information level (6).
82
83 LOG_DEBUG
84 Debug level (7).
85
86 The coap_set_log_level() function is used to set the current logging
87 level for output by any subsequent coap_log() calls. Output is only
88 logged if the coap_log() level definition is smaller than or equal to
89 the current logging level.
90
91 The coap_get_log_level() function is used to get the current logging
92 level.
93
94 The coap_dtls_set_log_level() function is used to set the logging level
95 for output by the DTLS library for specific DTLS information. Usually,
96 both coap_set_log_level() and coap_dtls_set_log_level() would be set to
97 the same level value. If the logging level is set to greater than
98 LOG_DEBUG, the underlying TLS library may get more verbose in its
99 output.
100
101 The coap_dtls_get_log_level() function is used to get the current
102 logging level for the DTLS library.
103
104 The coap_set_log_handler()* function can be used to define an
105 alternative logging handler for processing the logging messages. The
106 logging handler prototype is defined as:
107
108 typedef void (*coap_log_handler_t) (coap_log_t level, const char *message);
109
110 The coap_package_name() function returns the name of this library.
111
112 The coap_package_version() function returns the version of this
113 library.
114
115 The coap_package_build() function returns the git information (as in
116 "git describe --tags") for the build of this library or version of this
117 library if git is not used.
118
119 The coap_set_show_pdu_output() function defines whether the output from
120 coap_show_pdu() is to be either sent to stdout/stderr, or output using
121 coap_log(). use_fprintf is set to 1 for stdout/stderr (the default),
122 and use_fprintf is set to 0 for coap_log().
123
124 The coap_show_pdu() function is used to decode the pdu, outputting as
125 appropriate for logging level. Where the output goes is dependent on
126 coap_set_show_pdu_output().
127
128 The coap_endpoint_str() function returns a description string of the
129 endpoint.
130
131 The coap_session_str() function is used to get a string containing the
132 information about the session.
133
135 The coap_package_name(), coap_package_version() and
136 coap_package_build() return the appropriate zero-terminated character
137 string.
138
139 The coap_get_log_level() function returns the current logging level.
140
141 The coap_dtls_get_log_level() function returns the current logging
142 level for the DTLS library specifics.
143
144 The coap_endpoint_str() function returns a description string of the
145 endpoint.
146
147 The coap_session_str() function returns a description string of the
148 session.
149
151 coap_context(3) and coap_session(3)
152
154 See "RFC7252: The Constrained Application Protocol (CoAP)" for further
155 information.
156
158 Please report bugs on the mailing list for libcoap:
159 libcoap-developers@lists.sourceforge.net or raise an issue on GitHub at
160 https://github.com/obgm/libcoap/issues
161
163 The libcoap project <libcoap-developers@lists.sourceforge.net>
164
165
166
167coap_logging 4.3.1 01/19/2023 COAP_LOGGING(3)