0.01.00
logging.hpp
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2016, The OpenThread Authors.
3  * All rights reserved.
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted provided that the following conditions are met:
7  * 1. Redistributions of source code must retain the above copyright
8  * notice, this list of conditions and the following disclaimer.
9  * 2. Redistributions in binary form must reproduce the above copyright
10  * notice, this list of conditions and the following disclaimer in the
11  * documentation and/or other materials provided with the distribution.
12  * 3. Neither the name of the copyright holder nor the
13  * names of its contributors may be used to endorse or promote products
14  * derived from this software without specific prior written permission.
15  *
16  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
17  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
19  * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
20  * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
21  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
22  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
23  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
24  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
25  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
26  * POSSIBILITY OF SUCH DAMAGE.
27  */
28 
34 #ifndef LOGGING_HPP_
35 #define LOGGING_HPP_
36 
37 #include "openthread-core-config.h"
38 
39 #include <ctype.h>
40 #include <stdio.h>
41 #include "utils/wrap_string.h"
42 
43 #include <openthread/instance.h>
44 #include <openthread/types.h>
46 
47 #ifdef WINDOWS_LOGGING
48 #ifdef _KERNEL_MODE
49 #include <wdm.h>
50 #endif
52 #ifdef WPP_NAME
53 #include WPP_NAME
54 #endif
55 #endif
56 
57 #ifdef __cplusplus
58 extern "C" {
59 #endif
60 
61 #ifndef WINDOWS_LOGGING
62 #define otLogFuncEntry()
63 #define otLogFuncEntryMsg(aFormat, ...)
64 #define otLogFuncExit()
65 #define otLogFuncExitMsg(aFormat, ...)
66 #define otLogFuncExitErr(error)
67 #endif
68 
80 #if OPENTHREAD_CONFIG_LOG_LEVEL >= OT_LOG_LEVEL_CRIT
81 #define otLogCrit(aInstance, aRegion, aFormat, ...) \
82  _otLogFormatter(aInstance, OT_LOG_LEVEL_CRIT, aRegion, aFormat, ## __VA_ARGS__)
83 #else
84 #define otLogCrit(aInstance, aRegion, aFormat, ...)
85 #endif
86 
98 #if OPENTHREAD_CONFIG_LOG_LEVEL >= OT_LOG_LEVEL_WARN
99 #define otLogWarn(aInstance, aRegion, aFormat, ...) \
100  _otLogFormatter(aInstance, OT_LOG_LEVEL_WARN, aRegion, aFormat, ## __VA_ARGS__)
101 #else
102 #define otLogWarn(aInstance, aRegion, aFormat, ...)
103 #endif
104 
116 #if OPENTHREAD_CONFIG_LOG_LEVEL >= OT_LOG_LEVEL_INFO
117 #define otLogInfo(aInstance, aRegion, aFormat, ...) \
118  _otLogFormatter(aInstance, OT_LOG_LEVEL_INFO, aRegion, aFormat, ## __VA_ARGS__)
119 #else
120 #define otLogInfo(aInstance, aRegion, aFormat, ...)
121 #endif
122 
134 #if OPENTHREAD_CONFIG_LOG_LEVEL >= OT_LOG_LEVEL_DEBG
135 #define otLogDebg(aInstance, aRegion, aFormat, ...) \
136  _otLogFormatter(aInstance, OT_LOG_LEVEL_DEBG, aRegion, aFormat, ## __VA_ARGS__)
137 #else
138 #define otLogDebg(aInstance, aRegion, aFormat, ...)
139 #endif
140 
141 #ifndef WINDOWS_LOGGING
142 
186 #if OPENTHREAD_CONFIG_LOG_API == 1
187 #define otLogCritApi(aInstance, aFormat, ...) otLogCrit(&aInstance, OT_LOG_REGION_API, aFormat, ## __VA_ARGS__)
188 #define otLogWarnApi(aInstance, aFormat, ...) otLogWarn(&aInstance, OT_LOG_REGION_API, aFormat, ## __VA_ARGS__)
189 #define otLogInfoApi(aInstance, aFormat, ...) otLogInfo(&aInstance, OT_LOG_REGION_API, aFormat, ## __VA_ARGS__)
190 #define otLogDebgApi(aInstance, aFormat, ...) otLogDebg(&aInstance, OT_LOG_REGION_API, aFormat, ## __VA_ARGS__)
191 #else
192 #define otLogCritApi(aInstance, aFormat, ...)
193 #define otLogWarnApi(aInstance, aFormat, ...)
194 #define otLogInfoApi(aInstance, aFormat, ...)
195 #define otLogDebgApi(aInstance, aFormat, ...)
196 #endif
197 
242 #if OPENTHREAD_CONFIG_LOG_MLE == 1
243 #define otLogCritMeshCoP(aInstance, aFormat, ...) \
244  otLogCrit(&aInstance, OT_LOG_REGION_MESH_COP, aFormat, ## __VA_ARGS__)
245 #define otLogWarnMeshCoP(aInstance, aFormat, ...) \
246  otLogWarn(&aInstance, OT_LOG_REGION_MESH_COP, aFormat, ## __VA_ARGS__)
247 #define otLogInfoMeshCoP(aInstance, aFormat, ...) \
248  otLogInfo(&aInstance, OT_LOG_REGION_MESH_COP, aFormat, ## __VA_ARGS__)
249 #define otLogDebgMeshCoP(aInstance, aFormat, ...) \
250  otLogDebg(&aInstance, OT_LOG_REGION_MESH_COP, aFormat, ## __VA_ARGS__)
251 #else
252 #define otLogCritMeshCoP(aInstance, aFormat, ...)
253 #define otLogWarnMeshCoP(aInstance, aFormat, ...)
254 #define otLogInfoMeshCoP(aInstance, aFormat, ...)
255 #define otLogDebgMeshCoP(aInstance, aFormat, ...)
256 #endif
257 
258 #define otLogCritMbedTls(aInstance, aFormat, ...) otLogCritMeshCoP(aInstance, aFormat, ## __VA_ARGS__)
259 #define otLogWarnMbedTls(aInstance, aFormat, ...) otLogWarnMeshCoP(aInstance, aFormat, ## __VA_ARGS__)
260 #define otLogInfoMbedTls(aInstance, aFormat, ...) otLogInfoMeshCoP(aInstance, aFormat, ## __VA_ARGS__)
261 #define otLogDebgMbedTls(aInstance, aFormat, ...) otLogDebgMeshCoP(aInstance, aFormat, ## __VA_ARGS__)
262 
307 #if OPENTHREAD_CONFIG_LOG_MLE == 1
308 #define otLogCritMle(aInstance, aFormat, ...) otLogCrit(&aInstance, OT_LOG_REGION_MLE, aFormat, ## __VA_ARGS__)
309 #define otLogWarnMle(aInstance, aFormat, ...) otLogWarn(&aInstance, OT_LOG_REGION_MLE, aFormat, ## __VA_ARGS__)
310 #define otLogWarnMleErr(aInstance, aError, aFormat, ...) \
311  otLogWarn(&aInstance, OT_LOG_REGION_MLE, "Error %s: " aFormat, otThreadErrorToString(aError), ## __VA_ARGS__)
312 #define otLogInfoMle(aInstance, aFormat, ...) otLogInfo(&aInstance, OT_LOG_REGION_MLE, aFormat, ## __VA_ARGS__)
313 #define otLogDebgMle(aInstance, aFormat, ...) otLogDebg(&aInstance, OT_LOG_REGION_MLE, aFormat, ## __VA_ARGS__)
314 #else
315 #define otLogCritMle(aInstance, aFormat, ...)
316 #define otLogWarnMle(aInstance, aFormat, ...)
317 #define otLogWarnMleErr(aInstance, aError, aFormat, ...)
318 #define otLogInfoMle(aInstance, aFormat, ...)
319 #define otLogDebgMle(aInstance, aFormat, ...)
320 #endif
321 
366 #if OPENTHREAD_CONFIG_LOG_ARP == 1
367 #define otLogCritArp(aInstance, aFormat, ...) otLogCrit(&aInstance, OT_LOG_REGION_ARP, aFormat, ## __VA_ARGS__)
368 #define otLogWarnArp(aInstance, aFormat, ...) otLogWarn(&aInstance, OT_LOG_REGION_ARP, aFormat, ## __VA_ARGS__)
369 #define otLogInfoArp(aInstance, aFormat, ...) otLogInfo(&aInstance, OT_LOG_REGION_ARP, aFormat, ## __VA_ARGS__)
370 #define otLogDebgArp(aInstance, aFormat, ...) otLogDebg(&aInstance, OT_LOG_REGION_ARP, aFormat, ## __VA_ARGS__)
371 #else
372 #define otLogCritArp(aInstance, aFormat, ...)
373 #define otLogWarnArp(aInstance, aFormat, ...)
374 #define otLogInfoArp(aInstance, aFormat, ...)
375 #define otLogDebgArp(aInstance, aFormat, ...)
376 #endif
377 
421 #if OPENTHREAD_CONFIG_LOG_NETDATA == 1
422 #define otLogCritNetData(aInstance, aFormat, ...) \
423  otLogCrit(&aInstance, OT_LOG_REGION_NET_DATA, aFormat, ## __VA_ARGS__)
424 #define otLogWarnNetData(aInstance, aFormat, ...) \
425  otLogWarn(&aInstance, OT_LOG_REGION_NET_DATA, aFormat, ## __VA_ARGS__)
426 #define otLogInfoNetData(aInstance, aFormat, ...) \
427  otLogInfo(&aInstance, OT_LOG_REGION_NET_DATA, aFormat, ## __VA_ARGS__)
428 #define otLogDebgNetData(aInstance, aFormat, ...) \
429  otLogDebg(&aInstance, OT_LOG_REGION_NET_DATA, aFormat, ## __VA_ARGS__)
430 #else
431 #define otLogCritNetData(aInstance, aFormat, ...)
432 #define otLogWarnNetData(aInstance, aFormat, ...)
433 #define otLogInfoNetData(aInstance, aFormat, ...)
434 #define otLogDebgNetData(aInstance, aFormat, ...)
435 #endif
436 
480 #if OPENTHREAD_CONFIG_LOG_ICMP == 1
481 #define otLogCritIcmp(aInstance, aFormat, ...) otLogCrit(&aInstance, OT_LOG_REGION_ICMP, aFormat, ## __VA_ARGS__)
482 #define otLogWarnIcmp(aInstance, aFormat, ...) otLogWarn(&aInstance, OT_LOG_REGION_ICMP, aFormat, ## __VA_ARGS__)
483 #define otLogInfoIcmp(aInstance, aFormat, ...) otLogInfo(&aInstance, OT_LOG_REGION_ICMP, aFormat, ## __VA_ARGS__)
484 #define otLogDebgIcmp(aInstance, aFormat, ...) otLogDebg(&aInstance, OT_LOG_REGION_ICMP, aFormat, ## __VA_ARGS__)
485 #else
486 #define otLogCritIcmp(aInstance, aFormat, ...)
487 #define otLogWarnIcmp(aInstance, aFormat, ...)
488 #define otLogInfoIcmp(aInstance, aFormat, ...)
489 #define otLogDebgIcmp(aInstance, aFormat, ...)
490 #endif
491 
535 #if OPENTHREAD_CONFIG_LOG_IP6 == 1
536 #define otLogCritIp6(aInstance, aFormat, ...) otLogCrit(&aInstance, OT_LOG_REGION_IP6, aFormat, ## __VA_ARGS__)
537 #define otLogWarnIp6(aInstance, aFormat, ...) otLogWarn(&aInstance, OT_LOG_REGION_IP6, aFormat, ## __VA_ARGS__)
538 #define otLogInfoIp6(aInstance, aFormat, ...) otLogInfo(&aInstance, OT_LOG_REGION_IP6, aFormat, ## __VA_ARGS__)
539 #define otLogDebgIp6(aInstance, aFormat, ...) otLogDebg(&aInstance, OT_LOG_REGION_IP6, aFormat, ## __VA_ARGS__)
540 #else
541 #define otLogCritIp6(aInstance, aFormat, ...)
542 #define otLogWarnIp6(aInstance, aFormat, ...)
543 #define otLogInfoIp6(aInstance, aFormat, ...)
544 #define otLogDebgIp6(aInstance, aFormat, ...)
545 #endif
546 
591 #if OPENTHREAD_CONFIG_LOG_MAC == 1
592 #define otLogCritMac(aInstance, aFormat, ...) otLogCrit(&aInstance, OT_LOG_REGION_MAC, aFormat, ## __VA_ARGS__)
593 #define otLogWarnMac(aInstance, aFormat, ...) otLogWarn(&aInstance, OT_LOG_REGION_MAC, aFormat, ## __VA_ARGS__)
594 #define otLogInfoMac(aInstance, aFormat, ...) otLogInfo(&aInstance, OT_LOG_REGION_MAC, aFormat, ## __VA_ARGS__)
595 #define otLogDebgMac(aInstance, aFormat, ...) otLogDebg(&aInstance, OT_LOG_REGION_MAC, aFormat, ## __VA_ARGS__)
596 #define otLogDebgMacErr(aInstance, aError, aFormat, ...) \
597  otLogWarn(aInstance, OT_LOG_REGION_MAC, "Error %s: " aFormat, otThreadErrorToString(aError), ## __VA_ARGS__)
598 #else
599 #define otLogCritMac(aInstance, aFormat, ...)
600 #define otLogWarnMac(aInstance, aFormat, ...)
601 #define otLogInfoMac(aInstance, aFormat, ...)
602 #define otLogDebgMac(aInstance, aFormat, ...)
603 #define otLogDebgMacErr(aInstance, aError, aFormat, ...)
604 #endif
605 
651 #if OPENTHREAD_CONFIG_LOG_MEM == 1
652 #define otLogCritMem(aInstance, aFormat, ...) otLogCrit(&aInstance, OT_LOG_REGION_MEM, aFormat, ## __VA_ARGS__)
653 #define otLogWarnMem(aInstance, aFormat, ...) otLogWarn(&aInstance, OT_LOG_REGION_MEM, aFormat, ## __VA_ARGS__)
654 #define otLogInfoMem(aInstance, aFormat, ...) otLogInfo(&aInstance, OT_LOG_REGION_MEM, aFormat, ## __VA_ARGS__)
655 #define otLogDebgMem(aInstance, aFormat, ...) otLogDebg(&aInstance, OT_LOG_REGION_MEM, aFormat, ## __VA_ARGS__)
656 #else
657 #define otLogCritMem(aInstance, aFormat, ...)
658 #define otLogWarnMem(aInstance, aFormat, ...)
659 #define otLogInfoMem(aInstance, aFormat, ...)
660 #define otLogDebgMem(aInstance, aFormat, ...)
661 #endif
662 
706 #if OPENTHREAD_CONFIG_LOG_NETDIAG == 1
707 #define otLogCritNetDiag(aInstance, aFormat, ...) \
708  otLogCrit(&aInstance, OT_LOG_REGION_NET_DIAG, aFormat, ## __VA_ARGS__)
709 #define otLogWarnNetDiag(aInstance, aFormat, ...) \
710  otLogWarn(&aInstance, OT_LOG_REGION_NET_DIAG, aFormat, ## __VA_ARGS__)
711 #define otLogInfoNetDiag(aInstance, aFormat, ...) \
712  otLogInfo(&aInstance, OT_LOG_REGION_NET_DIAG, aFormat, ## __VA_ARGS__)
713 #define otLogDebgNetDiag(aInstance, aFormat, ...) \
714  otLogDebg(&aInstance, OT_LOG_REGION_NET_DIAG, aFormat, ## __VA_ARGS__)
715 #else
716 #define otLogCritNetDiag(aInstance, aFormat, ...)
717 #define otLogWarnNetDiag(aInstance, aFormat, ...)
718 #define otLogInfoNetDiag(aInstance, aFormat, ...)
719 #define otLogDebgNetDiag(aInstance, aFormat, ...)
720 #endif
721 
733 #if OPENTHREAD_ENABLE_CERT_LOG
734 #define otLogCertMeshCoP(aInstance, aFormat, ...) \
735  _otLogFormatter(&aInstance, OT_LOG_LEVEL_NONE, OT_LOG_REGION_MESH_COP, aFormat, ## __VA_ARGS__)
736 #else
737 #define otLogCertMeshCoP(aInstance, aFormat, ...)
738 #endif
739 
783 #if OPENTHREAD_CONFIG_LOG_CLI == 1
784 #define otLogCritCli(aInstance, aFormat, ...) otLogCrit(&aInstance, OT_LOG_REGION_CLI, aFormat, ## __VA_ARGS__)
785 #define otLogWarnCli(aInstance, aFormat, ...) otLogWarn(&aInstance, OT_LOG_REGION_CLI, aFormat, ## __VA_ARGS__)
786 #define otLogInfoCli(aInstance, aFormat, ...) otLogInfo(&aInstance, OT_LOG_REGION_CLI, aFormat, ## __VA_ARGS__)
787 #define otLogInfoCliErr(aInstance, aError, aFormat, ...) \
788  otLogInfo(&aInstance, OT_LOG_REGION_CLI, "Error %s: " aFormat, otThreadErrorToString(aError), ## __VA_ARGS__)
789 #define otLogDebgCli(aInstance, aFormat, ...) otLogDebg(&aInstance, OT_LOG_REGION_CLI, aFormat, ## __VA_ARGS__)
790 #else
791 #define otLogCritCli(aInstance, aFormat, ...)
792 #define otLogWarnCli(aInstance, aFormat, ...)
793 #define otLogInfoCli(aInstance, aFormat, ...)
794 #define otLogInfoCliErr(aInstance, aError, aFormat, ...)
795 #define otLogDebgCli(aInstance, aFormat, ...)
796 #endif
797 
841 #if OPENTHREAD_CONFIG_LOG_COAP == 1
842 #define otLogCritCoap(aInstance, aFormat, ...) otLogCrit(&aInstance, OT_LOG_REGION_COAP, aFormat, ## __VA_ARGS__)
843 #define otLogWarnCoap(aInstance, aFormat, ...) otLogWarn(&aInstance, OT_LOG_REGION_COAP, aFormat, ## __VA_ARGS__)
844 #define otLogInfoCoap(aInstance, aFormat, ...) otLogInfo(&aInstance, OT_LOG_REGION_COAP, aFormat, ## __VA_ARGS__)
845 #define otLogInfoCoapErr(aInstance, aError, aFormat, ...) \
846  otLogInfo(&aInstance, OT_LOG_REGION_COAP, "Error %s: " aFormat, otThreadErrorToString(aError), ## __VA_ARGS__)
847 #define otLogDebgCoap(aInstance, aFormat, ...) otLogDebg(&aInstance, OT_LOG_REGION_COAP, aFormat, ## __VA_ARGS__)
848 #else
849 #define otLogCritCoap(aInstance, aFormat, ...)
850 #define otLogWarnCoap(aInstance, aFormat, ...)
851 #define otLogInfoCoap(aInstance, aFormat, ...)
852 #define otLogInfoCoapErr(aInstance, aError, aFormat, ...)
853 #define otLogDebgCoap(aInstance, aFormat, ...)
854 #endif
855 
899 #if OPENTHREAD_CONFIG_LOG_PLATFORM == 1
900 #define otLogCritPlat(aInstance, aFormat, ...) otLogCrit(aInstance, OT_LOG_REGION_PLATFORM, aFormat, ## __VA_ARGS__)
901 #define otLogWarnPlat(aInstance, aFormat, ...) otLogWarn(aInstance, OT_LOG_REGION_PLATFORM, aFormat, ## __VA_ARGS__)
902 #define otLogInfoPlat(aInstance, aFormat, ...) otLogInfo(aInstance, OT_LOG_REGION_PLATFORM, aFormat, ## __VA_ARGS__)
903 #define otLogDebgPlat(aInstance, aFormat, ...) otLogDebg(aInstance, OT_LOG_REGION_PLATFORM, aFormat, ## __VA_ARGS__)
904 #else
905 #define otLogCritPlat(aInstance, aFormat, ...)
906 #define otLogWarnPlat(aInstance, aFormat, ...)
907 #define otLogInfoPlat(aInstance, aFormat, ...)
908 #define otLogDebgPlat(aInstance, aFormat, ...)
909 #endif
910 
911 #endif // WINDOWS_LOGGING
912 
925 #if OPENTHREAD_CONFIG_LOG_LEVEL >= OT_LOG_LEVEL_CRIT
926 #define otDumpCrit(aInstance, aRegion, aId, aBuf, aLength) \
927  otDump(&aInstance, OT_LOG_LEVEL_CRIT, aRegion, aId, aBuf, aLength)
928 #else
929 #define otDumpCrit(aInstance, aRegion, aId, aBuf, aLength)
930 #endif
931 
944 #if OPENTHREAD_CONFIG_LOG_LEVEL >= OT_LOG_LEVEL_WARN
945 #define otDumpWarn(aInstance, aRegion, aId, aBuf, aLength) \
946  otDump(&aInstance, OT_LOG_LEVEL_WARN, aRegion, aId, aBuf, aLength)
947 #else
948 #define otDumpWarn(aInstance, aRegion, aId, aBuf, aLength)
949 #endif
950 
963 #if OPENTHREAD_CONFIG_LOG_LEVEL >= OT_LOG_LEVEL_INFO
964 #define otDumpInfo(aInstance, aRegion, aId, aBuf, aLength) \
965  otDump(&aInstance, OT_LOG_LEVEL_INFO, aRegion, aId, aBuf, aLength)
966 #else
967 #define otDumpInfo(aInstance, aRegion, aId, aBuf, aLength)
968 #endif
969 
982 #if OPENTHREAD_CONFIG_LOG_LEVEL >= OT_LOG_LEVEL_DEBG
983 #define otDumpDebg(aInstance, aRegion, aId, aBuf, aLength) \
984  otDump(&aInstance, OT_LOG_LEVEL_DEBG, aRegion, aId, aBuf, aLength)
985 #else
986 #define otDumpDebg(aInstance, aRegion, aId, aBuf, aLength)
987 #endif
988 
1033 #if OPENTHREAD_CONFIG_LOG_NETDATA == 1
1034 #define otDumpCritNetData(aInstance, aId, aBuf, aLength) \
1035  otDumpCrit(aInstance, OT_LOG_REGION_NET_DATA, aId, aBuf, aLength)
1036 #define otDumpWarnNetData(aInstance, aId, aBuf, aLength) \
1037  otDumpWarn(aInstance, OT_LOG_REGION_NET_DATA, aId, aBuf, aLength)
1038 #define otDumpInfoNetData(aInstance, aId, aBuf, aLength) \
1039  otDumpInfo(aInstance, OT_LOG_REGION_NET_DATA, aId, aBuf, aLength)
1040 #define otDumpDebgNetData(aInstance, aId, aBuf, aLength) \
1041  otDumpDebg(aInstance, OT_LOG_REGION_NET_DATA, aId, aBuf, aLength)
1042 #else
1043 #define otDumpCritNetData(aInstance, aId, aBuf, aLength)
1044 #define otDumpWarnNetData(aInstance, aId, aBuf, aLength)
1045 #define otDumpInfoNetData(aInstance, aId, aBuf, aLength)
1046 #define otDumpDebgNetData(aInstance, aId, aBuf, aLength)
1047 #endif
1048 
1096 #if OPENTHREAD_CONFIG_LOG_MLE == 1
1097 #define otDumpCritMle(aInstance, aId, aBuf, aLength) otDumpCrit(aInstance, OT_LOG_REGION_MLE, aId, aBuf, aLength)
1098 #define otDumpWarnMle(aInstance, aId, aBuf, aLength) otDumpWarn(aInstance, OT_LOG_REGION_MLE, aId, aBuf, aLength)
1099 #define otDumpInfoMle(aInstance, aId, aBuf, aLength) otDumpInfo(aInstance, OT_LOG_REGION_MLE, aId, aBuf, aLength)
1100 #define otDumpDebgMle(aInstance, aId, aBuf, aLength) otDumpDebg(aInstance, OT_LOG_REGION_MLE, aId, aBuf, aLength)
1101 #else
1102 #define otDumpCritMle(aInstance, aId, aBuf, aLength)
1103 #define otDumpWarnMle(aInstance, aId, aBuf, aLength)
1104 #define otDumpInfoMle(aInstance, aId, aBuf, aLength)
1105 #define otDumpDebgMle(aInstance, aId, aBuf, aLength)
1106 #endif
1107 
1155 #if OPENTHREAD_CONFIG_LOG_ARP == 1
1156 #define otDumpCritArp(aInstance, aId, aBuf, aLength) otDumpCrit(aInstance, OT_LOG_REGION_ARP, aId, aBuf, aLength)
1157 #define otDumpWarnArp(aInstance, aId, aBuf, aLength) otDumpWarn(aInstance, OT_LOG_REGION_ARP, aId, aBuf, aLength)
1158 #define otDumpInfoArp(aInstance, aId, aBuf, aLength) otDumpInfo(aInstance, OT_LOG_REGION_ARP, aId, aBuf, aLength)
1159 #define otDumpDebgArp(aInstance, aId, aBuf, aLength) otDumpDebg(aInstance, OT_LOG_REGION_ARP, aId, aBuf, aLength)
1160 #else
1161 #define otDumpCritArp(aInstance, aId, aBuf, aLength)
1162 #define otDumpWarnArp(aInstance, aId, aBuf, aLength)
1163 #define otDumpInfoArp(aInstance, aId, aBuf, aLength)
1164 #define otDumpDebgArp(aInstance, aId, aBuf, aLength)
1165 #endif
1166 
1214 #if OPENTHREAD_CONFIG_LOG_ICMP == 1
1215 #define otDumpCritIcmp(aInstance, aId, aBuf, aLength) \
1216  otDumpCrit(aInstance, OT_LOG_REGION_ICMP, aId, aBuf, aLength)
1217 #define otDumpWarnIcmp(aInstance, aId, aBuf, aLength) \
1218  otDumpWarn(aInstance, OT_LOG_REGION_ICMP, aId, aBuf, aLength)
1219 #define otDumpInfoIcmp(aInstance, aId, aBuf, aLength) \
1220  otDumpInfo(aInstance, OT_LOG_REGION_ICMP, aId, aBuf, aLength)
1221 #define otDumpDebgIcmp(aInstance, aId, aBuf, aLength) \
1222  otDumpDebg(aInstance, OT_LOG_REGION_ICMP, aId, aBuf, aLength)
1223 #else
1224 #define otDumpCritIcmp(aInstance, aId, aBuf, aLength)
1225 #define otDumpWarnIcmp(aInstance, aId, aBuf, aLength)
1226 #define otDumpInfoIcmp(aInstance, aId, aBuf, aLength)
1227 #define otDumpDebgIcmp(aInstance, aId, aBuf, aLength)
1228 #endif
1229 
1277 #if OPENTHREAD_CONFIG_LOG_IP6 == 1
1278 #define otDumpCritIp6(aInstance, aId, aBuf, aLength) otDumpCrit(aInstance, OT_LOG_REGION_IP6, aId, aBuf, aLength)
1279 #define otDumpWarnIp6(aInstance, aId, aBuf, aLength) otDumpWarn(aInstance, OT_LOG_REGION_IP6, aId, aBuf, aLength)
1280 #define otDumpInfoIp6(aInstance, aId, aBuf, aLength) otDumpInfo(aInstance, OT_LOG_REGION_IP6, aId, aBuf, aLength)
1281 #define otDumpDebgIp6(aInstance, aId, aBuf, aLength) otDumpDebg(aInstance, OT_LOG_REGION_IP6, aId, aBuf, aLength)
1282 #else
1283 #define otDumpCritIp6(aInstance, aId, aBuf, aLength)
1284 #define otDumpWarnIp6(aInstance, aId, aBuf, aLength)
1285 #define otDumpInfoIp6(aInstance, aId, aBuf, aLength)
1286 #define otDumpDebgIp6(aInstance, aId, aBuf, aLength)
1287 #endif
1288 
1336 #if OPENTHREAD_CONFIG_LOG_MAC == 1
1337 #define otDumpCritMac(aInstance, aId, aBuf, aLength) otDumpCrit(aInstance, OT_LOG_REGION_MAC, aId, aBuf, aLength)
1338 #define otDumpWarnMac(aInstance, aId, aBuf, aLength) otDumpWarn(aInstance, OT_LOG_REGION_MAC, aId, aBuf, aLength)
1339 #define otDumpInfoMac(aInstance, aId, aBuf, aLength) otDumpInfo(aInstance, OT_LOG_REGION_MAC, aId, aBuf, aLength)
1340 #define otDumpDebgMac(aInstance, aId, aBuf, aLength) otDumpDebg(aInstance, OT_LOG_REGION_MAC, aId, aBuf, aLength)
1341 #else
1342 #define otDumpCritMac(aInstance, aId, aBuf, aLength)
1343 #define otDumpWarnMac(aInstance, aId, aBuf, aLength)
1344 #define otDumpInfoMac(aInstance, aId, aBuf, aLength)
1345 #define otDumpDebgMac(aInstance, aId, aBuf, aLength)
1346 #endif
1347 
1395 #if OPENTHREAD_CONFIG_LOG_MEM == 1
1396 #define otDumpCritMem(aInstance, aId, aBuf, aLength) otDumpCrit(aInstance, OT_LOG_REGION_MEM, aId, aBuf, aLength)
1397 #define otDumpWarnMem(aInstance, aId, aBuf, aLength) otDumpWarn(aInstance, OT_LOG_REGION_MEM, aId, aBuf, aLength)
1398 #define otDumpInfoMem(aInstance, aId, aBuf, aLength) otDumpInfo(aInstance, OT_LOG_REGION_MEM, aId, aBuf, aLength)
1399 #define otDumpDebgMem(aInstance, aId, aBuf, aLength) otDumpDebg(aInstance, OT_LOG_REGION_MEM, aId, aBuf, aLength)
1400 #else
1401 #define otDumpCritMem(aInstance, aId, aBuf, aLength)
1402 #define otDumpWarnMem(aInstance, aId, aBuf, aLength)
1403 #define otDumpInfoMem(aInstance, aId, aBuf, aLength)
1404 #define otDumpDebgMem(aInstance, aId, aBuf, aLength)
1405 #endif
1406 
1418 #if OPENTHREAD_ENABLE_CERT_LOG
1419 #define otDumpCertMeshCoP(aInstance, aId, aBuf, aLength) \
1420  otDump(&aInstance, OT_LOG_LEVEL_NONE, OT_LOG_REGION_MESH_COP, aId, aBuf, aLength)
1421 #else
1422 #define otDumpCertMeshCoP(aInstance, aId, aBuf, aLength)
1423 #endif
1424 
1436 void otDump(otInstance *aIntsance, otLogLevel aLevel, otLogRegion aRegion, const char *aId, const void *aBuf,
1437  const size_t aLength);
1438 
1439 #if OPENTHREAD_CONFIG_LOG_PREPEND_LEVEL == 1
1440 
1448 const char *otLogLevelToString(otLogLevel aLevel);
1449 #endif
1450 
1451 #if OPENTHREAD_CONFIG_LOG_PREPEND_REGION == 1
1452 
1460 const char *otLogRegionToString(otLogRegion aRegion);
1461 #endif
1462 
1463 #if OPENTHREAD_CONFIG_LOG_PREPEND_LEVEL == 1
1464 
1465 #if OPENTHREAD_CONFIG_LOG_PREPEND_REGION == 1
1466 
1470 #define _otLogFormatter(aInstance, aLogLevel, aRegion, aFormat, ...) \
1471  _otDynamicLog( \
1472  aInstance, \
1473  aLogLevel, \
1474  aRegion, \
1475  "[%s]%s: " aFormat OPENTHREAD_CONFIG_LOG_SUFFIX, \
1476  otLogLevelToString(aLogLevel), \
1477  otLogRegionToString(aRegion), \
1478  ## __VA_ARGS__ \
1479  )
1480 
1481 #else // OPENTHREAD_CONFIG_LOG_PREPEND_REGION
1482 
1486 #define _otLogFormatter(aInstanc, aLogLevel, aRegion, aFormat, ...) \
1487  _otDynamicLog( \
1488  aInstance, \
1489  aLogLevel, \
1490  aRegion, \
1491  "[%s]: " aFormat OPENTHREAD_CONFIG_LOG_SUFFIX, \
1492  otLogLevelToString(aLogLevel), \
1493  ## __VA_ARGS__ \
1494  )
1495 
1496 #endif
1497 
1498 #else // OPENTHREAD_CONFIG_LOG_PREPEND_LEVEL
1499 
1500 #if OPENTHREAD_CONFIG_LOG_PREPEND_REGION == 1
1501 
1505 #define _otLogFormatter(aInstance, aLogLevel, aRegion, aFormat, ...) \
1506  _otDynamicLog( \
1507  aInstance, \
1508  aLogLevel, \
1509  aRegion, \
1510  "%s: " aFormat OPENTHREAD_CONFIG_LOG_SUFFIX, \
1511  otLogRegionToString(aRegion), \
1512  ## __VA_ARGS__ \
1513  )
1514 
1515 #else // OPENTHREAD_CONFIG_LOG_PREPEND_REGION
1516 
1520 #define _otLogFormatter(aInstance, aLogLevel, aRegion, aFormat, ...) \
1521  _otDynamicLog( \
1522  aInstance, \
1523  aLogLevel, \
1524  aRegion, \
1525  aFormat OPENTHREAD_CONFIG_LOG_SUFFIX, \
1526  ## __VA_ARGS__ \
1527  )
1528 
1529 #endif
1530 
1531 #endif // OPENTHREAD_CONFIG_LOG_PREPEND_REGION
1532 
1533 #if OPENTHREAD_CONFIG_ENABLE_DYNAMIC_LOG_LEVEL == 1
1534 
1538 #define _otDynamicLog(aInstance, aLogLevel, aRegion, aFormat, ...) \
1539  do { \
1540  if (otGetDynamicLogLevel(aInstance) >= aLogLevel) \
1541  _otPlatLog(aLogLevel, aRegion, aFormat, ## __VA_ARGS__); \
1542  } while (false)
1543 
1544 #else // OPENTHREAD_CONFIG_ENABLE_DYNAMIC_LOG_LEVEL
1545 
1546 #define _otDynamicLog(aInstance, aLogLevel, aRegion, aFormat, ...) \
1547  _otPlatLog(aLogLevel, aRegion, aFormat, ## __VA_ARGS__)
1548 
1549 #endif // OPENTHREAD_CONFIG_ENABLE_DYNAMIC_LOG_LEVEL
1550 
1555 #define _otPlatLog(aLogLevel, aRegion, aFormat, ...) \
1556  OPENTHREAD_CONFIG_PLAT_LOG_FUNCTION(aLogLevel, aRegion, aFormat, ## __VA_ARGS__)
1557 
1558 #ifdef __cplusplus
1559 };
1560 #endif
1561 
1562 #endif // LOGGING_HPP_
This type represents all the static / global variables used by OpenThread allocated in one place...
Definition: openthread-instance.h:59
This file defines the types and structures used in the OpenThread library API.
uint8_t otLogLevel
Log levels.
Definition: types.h:1182
This file is a wrapper for the standard "string.h" file Some platforms provide all required functions...
This file defines the WPP Tracing Definitions.
This file includes the platform abstraction for the debug log service.
This file defines the OpenThread Instance API.
otLogRegion
This enum represents log regions.
Definition: types.h:1188
void otDump(otInstance *aIntsance, otLogLevel aLevel, otLogRegion aRegion, const char *aId, const void *aBuf, const size_t aLength)
This method dumps bytes to the log in a human-readable fashion.
Definition: logging.cpp:165
This file includes compile-time configuration constants for OpenThread.