xref: /aosp_15_r20/external/openthread/include/openthread/logging.h (revision cfb92d1480a9e65faed56933e9c12405f45898b4)
1*cfb92d14SAndroid Build Coastguard Worker /*
2*cfb92d14SAndroid Build Coastguard Worker  *  Copyright (c) 2016-2018, The OpenThread Authors.
3*cfb92d14SAndroid Build Coastguard Worker  *  All rights reserved.
4*cfb92d14SAndroid Build Coastguard Worker  *
5*cfb92d14SAndroid Build Coastguard Worker  *  Redistribution and use in source and binary forms, with or without
6*cfb92d14SAndroid Build Coastguard Worker  *  modification, are permitted provided that the following conditions are met:
7*cfb92d14SAndroid Build Coastguard Worker  *  1. Redistributions of source code must retain the above copyright
8*cfb92d14SAndroid Build Coastguard Worker  *     notice, this list of conditions and the following disclaimer.
9*cfb92d14SAndroid Build Coastguard Worker  *  2. Redistributions in binary form must reproduce the above copyright
10*cfb92d14SAndroid Build Coastguard Worker  *     notice, this list of conditions and the following disclaimer in the
11*cfb92d14SAndroid Build Coastguard Worker  *     documentation and/or other materials provided with the distribution.
12*cfb92d14SAndroid Build Coastguard Worker  *  3. Neither the name of the copyright holder nor the
13*cfb92d14SAndroid Build Coastguard Worker  *     names of its contributors may be used to endorse or promote products
14*cfb92d14SAndroid Build Coastguard Worker  *     derived from this software without specific prior written permission.
15*cfb92d14SAndroid Build Coastguard Worker  *
16*cfb92d14SAndroid Build Coastguard Worker  *  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
17*cfb92d14SAndroid Build Coastguard Worker  *  AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18*cfb92d14SAndroid Build Coastguard Worker  *  IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
19*cfb92d14SAndroid Build Coastguard Worker  *  ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
20*cfb92d14SAndroid Build Coastguard Worker  *  LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
21*cfb92d14SAndroid Build Coastguard Worker  *  CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
22*cfb92d14SAndroid Build Coastguard Worker  *  SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
23*cfb92d14SAndroid Build Coastguard Worker  *  INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
24*cfb92d14SAndroid Build Coastguard Worker  *  CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
25*cfb92d14SAndroid Build Coastguard Worker  *  ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
26*cfb92d14SAndroid Build Coastguard Worker  *  POSSIBILITY OF SUCH DAMAGE.
27*cfb92d14SAndroid Build Coastguard Worker  */
28*cfb92d14SAndroid Build Coastguard Worker 
29*cfb92d14SAndroid Build Coastguard Worker /**
30*cfb92d14SAndroid Build Coastguard Worker  * @file
31*cfb92d14SAndroid Build Coastguard Worker  * @brief
32*cfb92d14SAndroid Build Coastguard Worker  *   This file includes OpenThread logging related definitions.
33*cfb92d14SAndroid Build Coastguard Worker  */
34*cfb92d14SAndroid Build Coastguard Worker 
35*cfb92d14SAndroid Build Coastguard Worker #ifndef OPENTHREAD_LOGGING_H_
36*cfb92d14SAndroid Build Coastguard Worker #define OPENTHREAD_LOGGING_H_
37*cfb92d14SAndroid Build Coastguard Worker 
38*cfb92d14SAndroid Build Coastguard Worker #include <openthread/error.h>
39*cfb92d14SAndroid Build Coastguard Worker #include <openthread/platform/logging.h>
40*cfb92d14SAndroid Build Coastguard Worker 
41*cfb92d14SAndroid Build Coastguard Worker #ifdef __cplusplus
42*cfb92d14SAndroid Build Coastguard Worker extern "C" {
43*cfb92d14SAndroid Build Coastguard Worker #endif
44*cfb92d14SAndroid Build Coastguard Worker 
45*cfb92d14SAndroid Build Coastguard Worker /**
46*cfb92d14SAndroid Build Coastguard Worker  * @addtogroup api-logging
47*cfb92d14SAndroid Build Coastguard Worker  *
48*cfb92d14SAndroid Build Coastguard Worker  * @brief
49*cfb92d14SAndroid Build Coastguard Worker  *   This module includes OpenThread logging related definitions.
50*cfb92d14SAndroid Build Coastguard Worker  *
51*cfb92d14SAndroid Build Coastguard Worker  * @{
52*cfb92d14SAndroid Build Coastguard Worker  *
53*cfb92d14SAndroid Build Coastguard Worker  */
54*cfb92d14SAndroid Build Coastguard Worker 
55*cfb92d14SAndroid Build Coastguard Worker /**
56*cfb92d14SAndroid Build Coastguard Worker  * Returns the current log level.
57*cfb92d14SAndroid Build Coastguard Worker  *
58*cfb92d14SAndroid Build Coastguard Worker  * If dynamic log level feature `OPENTHREAD_CONFIG_LOG_LEVEL_DYNAMIC_ENABLE` is enabled, this function returns the
59*cfb92d14SAndroid Build Coastguard Worker  * currently set dynamic log level. Otherwise, this function returns the build-time configured log level.
60*cfb92d14SAndroid Build Coastguard Worker  *
61*cfb92d14SAndroid Build Coastguard Worker  * @returns The log level.
62*cfb92d14SAndroid Build Coastguard Worker  *
63*cfb92d14SAndroid Build Coastguard Worker  */
64*cfb92d14SAndroid Build Coastguard Worker otLogLevel otLoggingGetLevel(void);
65*cfb92d14SAndroid Build Coastguard Worker 
66*cfb92d14SAndroid Build Coastguard Worker /**
67*cfb92d14SAndroid Build Coastguard Worker  * Sets the log level.
68*cfb92d14SAndroid Build Coastguard Worker  *
69*cfb92d14SAndroid Build Coastguard Worker  * @note This function requires `OPENTHREAD_CONFIG_LOG_LEVEL_DYNAMIC_ENABLE=1`.
70*cfb92d14SAndroid Build Coastguard Worker  *
71*cfb92d14SAndroid Build Coastguard Worker  * @param[in]  aLogLevel               The log level.
72*cfb92d14SAndroid Build Coastguard Worker  *
73*cfb92d14SAndroid Build Coastguard Worker  * @retval OT_ERROR_NONE            Successfully updated log level.
74*cfb92d14SAndroid Build Coastguard Worker  * @retval OT_ERROR_INVALID_ARGS    Log level value is invalid.
75*cfb92d14SAndroid Build Coastguard Worker  *
76*cfb92d14SAndroid Build Coastguard Worker  */
77*cfb92d14SAndroid Build Coastguard Worker otError otLoggingSetLevel(otLogLevel aLogLevel);
78*cfb92d14SAndroid Build Coastguard Worker 
79*cfb92d14SAndroid Build Coastguard Worker /**
80*cfb92d14SAndroid Build Coastguard Worker  * Emits a log message at critical log level.
81*cfb92d14SAndroid Build Coastguard Worker  *
82*cfb92d14SAndroid Build Coastguard Worker  * Is intended for use by platform. If `OPENTHREAD_CONFIG_LOG_PLATFORM` is not set or the current log
83*cfb92d14SAndroid Build Coastguard Worker  * level is below critical, this function does not emit any log message.
84*cfb92d14SAndroid Build Coastguard Worker  *
85*cfb92d14SAndroid Build Coastguard Worker  * @param[in]  aFormat  The format string.
86*cfb92d14SAndroid Build Coastguard Worker  * @param[in]  ...      Arguments for the format specification.
87*cfb92d14SAndroid Build Coastguard Worker  *
88*cfb92d14SAndroid Build Coastguard Worker  */
89*cfb92d14SAndroid Build Coastguard Worker void otLogCritPlat(const char *aFormat, ...) OT_TOOL_PRINTF_STYLE_FORMAT_ARG_CHECK(1, 2);
90*cfb92d14SAndroid Build Coastguard Worker 
91*cfb92d14SAndroid Build Coastguard Worker /**
92*cfb92d14SAndroid Build Coastguard Worker  * Emits a log message at warning log level.
93*cfb92d14SAndroid Build Coastguard Worker  *
94*cfb92d14SAndroid Build Coastguard Worker  * Is intended for use by platform. If `OPENTHREAD_CONFIG_LOG_PLATFORM` is not set or the current log
95*cfb92d14SAndroid Build Coastguard Worker  * level is below warning, this function does not emit any log message.
96*cfb92d14SAndroid Build Coastguard Worker  *
97*cfb92d14SAndroid Build Coastguard Worker  * @param[in]  aFormat  The format string.
98*cfb92d14SAndroid Build Coastguard Worker  * @param[in]  ...      Arguments for the format specification.
99*cfb92d14SAndroid Build Coastguard Worker  *
100*cfb92d14SAndroid Build Coastguard Worker  */
101*cfb92d14SAndroid Build Coastguard Worker void otLogWarnPlat(const char *aFormat, ...) OT_TOOL_PRINTF_STYLE_FORMAT_ARG_CHECK(1, 2);
102*cfb92d14SAndroid Build Coastguard Worker 
103*cfb92d14SAndroid Build Coastguard Worker /**
104*cfb92d14SAndroid Build Coastguard Worker  * Emits a log message at note log level.
105*cfb92d14SAndroid Build Coastguard Worker  *
106*cfb92d14SAndroid Build Coastguard Worker  * Is intended for use by platform. If `OPENTHREAD_CONFIG_LOG_PLATFORM` is not set or the current log
107*cfb92d14SAndroid Build Coastguard Worker  * level is below note, this function does not emit any log message.
108*cfb92d14SAndroid Build Coastguard Worker  *
109*cfb92d14SAndroid Build Coastguard Worker  * @param[in]  aFormat  The format string.
110*cfb92d14SAndroid Build Coastguard Worker  * @param[in]  ...      Arguments for the format specification.
111*cfb92d14SAndroid Build Coastguard Worker  *
112*cfb92d14SAndroid Build Coastguard Worker  */
113*cfb92d14SAndroid Build Coastguard Worker void otLogNotePlat(const char *aFormat, ...) OT_TOOL_PRINTF_STYLE_FORMAT_ARG_CHECK(1, 2);
114*cfb92d14SAndroid Build Coastguard Worker 
115*cfb92d14SAndroid Build Coastguard Worker /**
116*cfb92d14SAndroid Build Coastguard Worker  * Emits a log message at info log level.
117*cfb92d14SAndroid Build Coastguard Worker  *
118*cfb92d14SAndroid Build Coastguard Worker  * Is intended for use by platform. If `OPENTHREAD_CONFIG_LOG_PLATFORM` is not set or the current log
119*cfb92d14SAndroid Build Coastguard Worker  * level is below info, this function does not emit any log message.
120*cfb92d14SAndroid Build Coastguard Worker  *
121*cfb92d14SAndroid Build Coastguard Worker  * @param[in]  aFormat  The format string.
122*cfb92d14SAndroid Build Coastguard Worker  * @param[in]  ...      Arguments for the format specification.
123*cfb92d14SAndroid Build Coastguard Worker  *
124*cfb92d14SAndroid Build Coastguard Worker  */
125*cfb92d14SAndroid Build Coastguard Worker void otLogInfoPlat(const char *aFormat, ...) OT_TOOL_PRINTF_STYLE_FORMAT_ARG_CHECK(1, 2);
126*cfb92d14SAndroid Build Coastguard Worker 
127*cfb92d14SAndroid Build Coastguard Worker /**
128*cfb92d14SAndroid Build Coastguard Worker  * Emits a log message at debug log level.
129*cfb92d14SAndroid Build Coastguard Worker  *
130*cfb92d14SAndroid Build Coastguard Worker  * Is intended for use by platform. If `OPENTHREAD_CONFIG_LOG_PLATFORM` is not set or the current log
131*cfb92d14SAndroid Build Coastguard Worker  * level is below debug, this function does not emit any log message.
132*cfb92d14SAndroid Build Coastguard Worker  *
133*cfb92d14SAndroid Build Coastguard Worker  * @param[in]  aFormat  The format string.
134*cfb92d14SAndroid Build Coastguard Worker  * @param[in]  ...      Arguments for the format specification.
135*cfb92d14SAndroid Build Coastguard Worker  *
136*cfb92d14SAndroid Build Coastguard Worker  */
137*cfb92d14SAndroid Build Coastguard Worker void otLogDebgPlat(const char *aFormat, ...) OT_TOOL_PRINTF_STYLE_FORMAT_ARG_CHECK(1, 2);
138*cfb92d14SAndroid Build Coastguard Worker 
139*cfb92d14SAndroid Build Coastguard Worker /**
140*cfb92d14SAndroid Build Coastguard Worker  * Generates a memory dump at critical log level.
141*cfb92d14SAndroid Build Coastguard Worker  *
142*cfb92d14SAndroid Build Coastguard Worker  * If `OPENTHREAD_CONFIG_LOG_PLATFORM` or `OPENTHREAD_CONFIG_LOG_PKT_DUMP` is not set or the current log level is below
143*cfb92d14SAndroid Build Coastguard Worker  * critical this function does not emit any log message.
144*cfb92d14SAndroid Build Coastguard Worker  *
145*cfb92d14SAndroid Build Coastguard Worker  * @param[in]  aText         A string that is printed before the bytes.
146*cfb92d14SAndroid Build Coastguard Worker  * @param[in]  aData         A pointer to the data buffer.
147*cfb92d14SAndroid Build Coastguard Worker  * @param[in]  aDataLength   Number of bytes in @p aData.
148*cfb92d14SAndroid Build Coastguard Worker  *
149*cfb92d14SAndroid Build Coastguard Worker  */
150*cfb92d14SAndroid Build Coastguard Worker void otDumpCritPlat(const char *aText, const void *aData, uint16_t aDataLength);
151*cfb92d14SAndroid Build Coastguard Worker 
152*cfb92d14SAndroid Build Coastguard Worker /**
153*cfb92d14SAndroid Build Coastguard Worker  * Generates a memory dump at warning log level.
154*cfb92d14SAndroid Build Coastguard Worker  *
155*cfb92d14SAndroid Build Coastguard Worker  * If `OPENTHREAD_CONFIG_LOG_PLATFORM` or `OPENTHREAD_CONFIG_LOG_PKT_DUMP` is not set or the current log level is below
156*cfb92d14SAndroid Build Coastguard Worker  * warning this function does not emit any log message.
157*cfb92d14SAndroid Build Coastguard Worker  *
158*cfb92d14SAndroid Build Coastguard Worker  * @param[in]  aText         A string that is printed before the bytes.
159*cfb92d14SAndroid Build Coastguard Worker  * @param[in]  aData         A pointer to the data buffer.
160*cfb92d14SAndroid Build Coastguard Worker  * @param[in]  aDataLength   Number of bytes in @p aData.
161*cfb92d14SAndroid Build Coastguard Worker  *
162*cfb92d14SAndroid Build Coastguard Worker  */
163*cfb92d14SAndroid Build Coastguard Worker void otDumpWarnPlat(const char *aText, const void *aData, uint16_t aDataLength);
164*cfb92d14SAndroid Build Coastguard Worker 
165*cfb92d14SAndroid Build Coastguard Worker /**
166*cfb92d14SAndroid Build Coastguard Worker  * Generates a memory dump at note log level.
167*cfb92d14SAndroid Build Coastguard Worker  *
168*cfb92d14SAndroid Build Coastguard Worker  * If `OPENTHREAD_CONFIG_LOG_PLATFORM` or `OPENTHREAD_CONFIG_LOG_PKT_DUMP` is not set or the current log level is below
169*cfb92d14SAndroid Build Coastguard Worker  * note this function does not emit any log message.
170*cfb92d14SAndroid Build Coastguard Worker  *
171*cfb92d14SAndroid Build Coastguard Worker  * @param[in]  aText         A string that is printed before the bytes.
172*cfb92d14SAndroid Build Coastguard Worker  * @param[in]  aData         A pointer to the data buffer.
173*cfb92d14SAndroid Build Coastguard Worker  * @param[in]  aDataLength   Number of bytes in @p aData.
174*cfb92d14SAndroid Build Coastguard Worker  *
175*cfb92d14SAndroid Build Coastguard Worker  */
176*cfb92d14SAndroid Build Coastguard Worker void otDumpNotePlat(const char *aText, const void *aData, uint16_t aDataLength);
177*cfb92d14SAndroid Build Coastguard Worker 
178*cfb92d14SAndroid Build Coastguard Worker /**
179*cfb92d14SAndroid Build Coastguard Worker  * Generates a memory dump at info log level.
180*cfb92d14SAndroid Build Coastguard Worker  *
181*cfb92d14SAndroid Build Coastguard Worker  * If `OPENTHREAD_CONFIG_LOG_PLATFORM` or `OPENTHREAD_CONFIG_LOG_PKT_DUMP` is not set or the current log level is below
182*cfb92d14SAndroid Build Coastguard Worker  * info this function does not emit any log message.
183*cfb92d14SAndroid Build Coastguard Worker  *
184*cfb92d14SAndroid Build Coastguard Worker  * @param[in]  aText         A string that is printed before the bytes.
185*cfb92d14SAndroid Build Coastguard Worker  * @param[in]  aData         A pointer to the data buffer.
186*cfb92d14SAndroid Build Coastguard Worker  * @param[in]  aDataLength   Number of bytes in @p aData.
187*cfb92d14SAndroid Build Coastguard Worker  *
188*cfb92d14SAndroid Build Coastguard Worker  */
189*cfb92d14SAndroid Build Coastguard Worker void otDumpInfoPlat(const char *aText, const void *aData, uint16_t aDataLength);
190*cfb92d14SAndroid Build Coastguard Worker 
191*cfb92d14SAndroid Build Coastguard Worker /**
192*cfb92d14SAndroid Build Coastguard Worker  * Generates a memory dump at debug log level.
193*cfb92d14SAndroid Build Coastguard Worker  *
194*cfb92d14SAndroid Build Coastguard Worker  * If `OPENTHREAD_CONFIG_LOG_PLATFORM` or `OPENTHREAD_CONFIG_LOG_PKT_DUMP` is not set or the current log level is below
195*cfb92d14SAndroid Build Coastguard Worker  * debug this function does not emit any log message.
196*cfb92d14SAndroid Build Coastguard Worker  *
197*cfb92d14SAndroid Build Coastguard Worker  * @param[in]  aText         A string that is printed before the bytes.
198*cfb92d14SAndroid Build Coastguard Worker  * @param[in]  aData         A pointer to the data buffer.
199*cfb92d14SAndroid Build Coastguard Worker  * @param[in]  aDataLength   Number of bytes in @p aData.
200*cfb92d14SAndroid Build Coastguard Worker  *
201*cfb92d14SAndroid Build Coastguard Worker  */
202*cfb92d14SAndroid Build Coastguard Worker void otDumpDebgPlat(const char *aText, const void *aData, uint16_t aDataLength);
203*cfb92d14SAndroid Build Coastguard Worker 
204*cfb92d14SAndroid Build Coastguard Worker /**
205*cfb92d14SAndroid Build Coastguard Worker  * Emits a log message at given log level using a platform module name.
206*cfb92d14SAndroid Build Coastguard Worker  *
207*cfb92d14SAndroid Build Coastguard Worker  * This is is intended for use by platform. If `OPENTHREAD_CONFIG_LOG_PLATFORM` is not set or the current log
208*cfb92d14SAndroid Build Coastguard Worker  * level is below @p aLogLevel , this function does not emit any log message.
209*cfb92d14SAndroid Build Coastguard Worker  *
210*cfb92d14SAndroid Build Coastguard Worker  * The @p aPlatModuleName name is used to determine the log module name in the emitted log message, following the
211*cfb92d14SAndroid Build Coastguard Worker  * `P-{PlatModuleName}---` format. This means that the prefix string "P-" is added to indicate that this is a platform
212*cfb92d14SAndroid Build Coastguard Worker  * sub-module, followed by the next 12 characters of the @p PlatModuleName string, with padded hyphens `-` at the end
213*cfb92d14SAndroid Build Coastguard Worker  * to ensure that the region name is 14 characters long.
214*cfb92d14SAndroid Build Coastguard Worker 
215*cfb92d14SAndroid Build Coastguard Worker  * @param[in] aLogLevel         The log level.
216*cfb92d14SAndroid Build Coastguard Worker  * @param[in] aPlatModuleName   The platform sub-module name.
217*cfb92d14SAndroid Build Coastguard Worker  * @param[in] aFormat           The format string.
218*cfb92d14SAndroid Build Coastguard Worker  * @param[in] ...               Arguments for the format specification.
219*cfb92d14SAndroid Build Coastguard Worker  *
220*cfb92d14SAndroid Build Coastguard Worker  */
221*cfb92d14SAndroid Build Coastguard Worker void otLogPlat(otLogLevel aLogLevel, const char *aPlatModuleName, const char *aFormat, ...)
222*cfb92d14SAndroid Build Coastguard Worker     OT_TOOL_PRINTF_STYLE_FORMAT_ARG_CHECK(3, 4);
223*cfb92d14SAndroid Build Coastguard Worker 
224*cfb92d14SAndroid Build Coastguard Worker /**
225*cfb92d14SAndroid Build Coastguard Worker  * Emits a log message at given log level using a platform module name.
226*cfb92d14SAndroid Build Coastguard Worker  *
227*cfb92d14SAndroid Build Coastguard Worker  * This is is intended for use by platform. If `OPENTHREAD_CONFIG_LOG_PLATFORM` is not set or the current log
228*cfb92d14SAndroid Build Coastguard Worker  * level is below @p aLogLevel , this function does not emit any log message.
229*cfb92d14SAndroid Build Coastguard Worker  *
230*cfb92d14SAndroid Build Coastguard Worker  * The @p aPlatModuleName name is used to determine the log module name in the emitted log message, following the
231*cfb92d14SAndroid Build Coastguard Worker  * `P-{PlatModuleName}---` format. This means that the prefix string "P-" is added to indicate that this is a platform
232*cfb92d14SAndroid Build Coastguard Worker  * sub-module, followed by the next 12 characters of the @p PlatModuleName string, with padded hyphens `-` at the end
233*cfb92d14SAndroid Build Coastguard Worker  * to ensure that the region name is 14 characters long.
234*cfb92d14SAndroid Build Coastguard Worker  *
235*cfb92d14SAndroid Build Coastguard Worker  * @param[in] aLogLevel         The log level.
236*cfb92d14SAndroid Build Coastguard Worker  * @param[in] aPlatModuleName   The platform sub-module name.
237*cfb92d14SAndroid Build Coastguard Worker  * @param[in] aFormat           The format string.
238*cfb92d14SAndroid Build Coastguard Worker  * @param[in] aArgs             Arguments for the format specification.
239*cfb92d14SAndroid Build Coastguard Worker  *
240*cfb92d14SAndroid Build Coastguard Worker  */
241*cfb92d14SAndroid Build Coastguard Worker void otLogPlatArgs(otLogLevel aLogLevel, const char *aPlatModuleName, const char *aFormat, va_list aArgs);
242*cfb92d14SAndroid Build Coastguard Worker 
243*cfb92d14SAndroid Build Coastguard Worker /**
244*cfb92d14SAndroid Build Coastguard Worker  * Emits a log message at a given log level.
245*cfb92d14SAndroid Build Coastguard Worker  *
246*cfb92d14SAndroid Build Coastguard Worker  * Is intended for use by CLI only. If `OPENTHREAD_CONFIG_LOG_CLI` is not set or the current log
247*cfb92d14SAndroid Build Coastguard Worker  * level is below the given log level, this function does not emit any log message.
248*cfb92d14SAndroid Build Coastguard Worker  *
249*cfb92d14SAndroid Build Coastguard Worker  * @param[in]  aLogLevel The log level.
250*cfb92d14SAndroid Build Coastguard Worker  * @param[in]  aFormat   The format string.
251*cfb92d14SAndroid Build Coastguard Worker  * @param[in]  ...       Arguments for the format specification.
252*cfb92d14SAndroid Build Coastguard Worker  *
253*cfb92d14SAndroid Build Coastguard Worker  */
254*cfb92d14SAndroid Build Coastguard Worker void otLogCli(otLogLevel aLogLevel, const char *aFormat, ...) OT_TOOL_PRINTF_STYLE_FORMAT_ARG_CHECK(2, 3);
255*cfb92d14SAndroid Build Coastguard Worker 
256*cfb92d14SAndroid Build Coastguard Worker #define OT_LOG_HEX_DUMP_LINE_SIZE 73 ///< Hex dump line string size.
257*cfb92d14SAndroid Build Coastguard Worker 
258*cfb92d14SAndroid Build Coastguard Worker /**
259*cfb92d14SAndroid Build Coastguard Worker  * Represents information used for generating hex dump output.
260*cfb92d14SAndroid Build Coastguard Worker  *
261*cfb92d14SAndroid Build Coastguard Worker  */
262*cfb92d14SAndroid Build Coastguard Worker typedef struct
263*cfb92d14SAndroid Build Coastguard Worker {
264*cfb92d14SAndroid Build Coastguard Worker     const uint8_t *mDataBytes;                       ///< The data byes.
265*cfb92d14SAndroid Build Coastguard Worker     uint16_t       mDataLength;                      ///< The data length (number of bytes in @p mDataBytes)
266*cfb92d14SAndroid Build Coastguard Worker     const char    *mTitle;                           ///< Title string to add table header (MUST NOT be `NULL`).
267*cfb92d14SAndroid Build Coastguard Worker     char           mLine[OT_LOG_HEX_DUMP_LINE_SIZE]; ///< Buffer to output one line of generated hex dump.
268*cfb92d14SAndroid Build Coastguard Worker     uint16_t       mIterator;                        ///< Iterator used by OT stack. MUST be initialized to zero.
269*cfb92d14SAndroid Build Coastguard Worker } otLogHexDumpInfo;
270*cfb92d14SAndroid Build Coastguard Worker 
271*cfb92d14SAndroid Build Coastguard Worker /**
272*cfb92d14SAndroid Build Coastguard Worker  * Generates the next hex dump line.
273*cfb92d14SAndroid Build Coastguard Worker  *
274*cfb92d14SAndroid Build Coastguard Worker  * Can call this method back-to-back to generate the hex dump output line by line. On the first call the `mIterator`
275*cfb92d14SAndroid Build Coastguard Worker  * field in @p aInfo MUST be set to zero.
276*cfb92d14SAndroid Build Coastguard Worker  *
277*cfb92d14SAndroid Build Coastguard Worker  * Here is an example of the generated hex dump output:
278*cfb92d14SAndroid Build Coastguard Worker  *
279*cfb92d14SAndroid Build Coastguard Worker  *  "==========================[{mTitle} len=070]============================"
280*cfb92d14SAndroid Build Coastguard Worker  *  "| 41 D8 87 34 12 FF FF 25 | 4C 57 DA F2 FB 2F 62 7F | A..4...%LW.../b. |"
281*cfb92d14SAndroid Build Coastguard Worker  *  "| 3B 01 F0 4D 4C 4D 4C 54 | 4F 00 15 15 00 00 00 00 | ;..MLMLTO....... |"
282*cfb92d14SAndroid Build Coastguard Worker  *  "| 00 00 00 01 80 DB 60 82 | 7E 33 72 3B CC B3 A1 84 | ......`.~3r;.... |"
283*cfb92d14SAndroid Build Coastguard Worker  *  "| 3B E6 AD B2 0B 45 E7 45 | C5 B9 00 1A CB 2D 6D 1C | ;....E.E.....-m. |"
284*cfb92d14SAndroid Build Coastguard Worker  *  "| 10 3E 3C F5 D3 70       |                         | .><..p           |"
285*cfb92d14SAndroid Build Coastguard Worker  *  "------------------------------------------------------------------------"
286*cfb92d14SAndroid Build Coastguard Worker  *
287*cfb92d14SAndroid Build Coastguard Worker  * @param[in,out] aInfo        A pointer to `otLogHexDumpInfo` to use to generate hex dump.
288*cfb92d14SAndroid Build Coastguard Worker  *
289*cfb92d14SAndroid Build Coastguard Worker  * @retval OT_ERROR_NONE       Successfully generated the next line, `mLine` field in @p aInfo is updated.
290*cfb92d14SAndroid Build Coastguard Worker  * @retval OT_ERROR_NOT_FOUND  Reached the end and no more line to generate.
291*cfb92d14SAndroid Build Coastguard Worker  *
292*cfb92d14SAndroid Build Coastguard Worker  */
293*cfb92d14SAndroid Build Coastguard Worker otError otLogGenerateNextHexDumpLine(otLogHexDumpInfo *aInfo);
294*cfb92d14SAndroid Build Coastguard Worker 
295*cfb92d14SAndroid Build Coastguard Worker /**
296*cfb92d14SAndroid Build Coastguard Worker  * @}
297*cfb92d14SAndroid Build Coastguard Worker  *
298*cfb92d14SAndroid Build Coastguard Worker  */
299*cfb92d14SAndroid Build Coastguard Worker 
300*cfb92d14SAndroid Build Coastguard Worker #ifdef __cplusplus
301*cfb92d14SAndroid Build Coastguard Worker } // extern "C"
302*cfb92d14SAndroid Build Coastguard Worker #endif
303*cfb92d14SAndroid Build Coastguard Worker 
304*cfb92d14SAndroid Build Coastguard Worker #endif // OPENTHREAD_LOGGING_H_
305