1 /* 2 * Copyright (c) 2019, 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 29 /** 30 * @file 31 * This file includes compile-time configurations for the logging service. 32 * 33 */ 34 35 #ifndef CONFIG_LOGGING_H_ 36 #define CONFIG_LOGGING_H_ 37 38 /** 39 * @def OPENTHREAD_CONFIG_LOG_OUTPUT 40 * 41 * Selects if, and where the LOG output goes to. 42 * 43 * There are several options available 44 * - @sa OPENTHREAD_CONFIG_LOG_OUTPUT_NONE 45 * - @sa OPENTHREAD_CONFIG_LOG_OUTPUT_DEBUG_UART 46 * - @sa OPENTHREAD_CONFIG_LOG_OUTPUT_APP 47 * - @sa OPENTHREAD_CONFIG_LOG_OUTPUT_PLATFORM_DEFINED 48 * - and others 49 * 50 * Note: 51 * 52 * 1) Because the default is: OPENTHREAD_CONFIG_LOG_OUTPUT_PLATFORM_DEFINED 53 * The platform is expected to provide at least a stub for `otPlatLog()`. 54 * 55 * 2) This is effectively an ENUM so it can be if/else/endif at compile time. 56 * 57 */ 58 #ifndef OPENTHREAD_CONFIG_LOG_OUTPUT 59 #define OPENTHREAD_CONFIG_LOG_OUTPUT OPENTHREAD_CONFIG_LOG_OUTPUT_PLATFORM_DEFINED 60 #endif 61 62 /** Log output goes to the bit bucket (disabled) */ 63 #define OPENTHREAD_CONFIG_LOG_OUTPUT_NONE 0 64 /** Log output goes to the debug uart - requires OPENTHREAD_CONFIG_ENABLE_DEBUG_UART to be enabled */ 65 #define OPENTHREAD_CONFIG_LOG_OUTPUT_DEBUG_UART 1 66 /** Log output goes to the "application" provided otPlatLog() in NCP and CLI code */ 67 #define OPENTHREAD_CONFIG_LOG_OUTPUT_APP 2 68 /** Log output is handled by a platform defined function */ 69 #define OPENTHREAD_CONFIG_LOG_OUTPUT_PLATFORM_DEFINED 3 70 71 /** 72 * @def OPENTHREAD_CONFIG_LOG_LEVEL 73 * 74 * The log level (used at compile time). If `OPENTHREAD_CONFIG_LOG_LEVEL_DYNAMIC_ENABLE` is set, this defines the most 75 * verbose log level possible. See `OPENTHREAD_CONFIG_LOG_LEVEL_INIT` to set the initial log level. 76 * 77 */ 78 #ifndef OPENTHREAD_CONFIG_LOG_LEVEL 79 #define OPENTHREAD_CONFIG_LOG_LEVEL OT_LOG_LEVEL_CRIT 80 #endif 81 82 /** 83 * @def OPENTHREAD_CONFIG_LOG_LEVEL_DYNAMIC_ENABLE 84 * 85 * Define as 1 to enable dynamic log level control. 86 * 87 * Note that the OPENTHREAD_CONFIG_LOG_LEVEL determines the log level at 88 * compile time. The dynamic log level control (if enabled) only allows 89 * decreasing the log level from the compile time value. 90 * 91 */ 92 #ifndef OPENTHREAD_CONFIG_LOG_LEVEL_DYNAMIC_ENABLE 93 #define OPENTHREAD_CONFIG_LOG_LEVEL_DYNAMIC_ENABLE 0 94 #endif 95 96 /** 97 * @def OPENTHREAD_CONFIG_LOG_LEVEL_INIT 98 * 99 * The initial log level used when OpenThread is initialized. See 100 * `OPENTHREAD_CONFIG_LOG_LEVEL_DYNAMIC_ENABLE`. 101 */ 102 #ifndef OPENTHREAD_CONFIG_LOG_LEVEL_INIT 103 #define OPENTHREAD_CONFIG_LOG_LEVEL_INIT OPENTHREAD_CONFIG_LOG_LEVEL 104 #endif 105 106 /** 107 * @def OPENTHREAD_CONFIG_LOG_API 108 * 109 * Define to enable OpenThread API logging. 110 * 111 */ 112 #ifndef OPENTHREAD_CONFIG_LOG_API 113 #define OPENTHREAD_CONFIG_LOG_API 1 114 #endif 115 116 /** 117 * @def OPENTHREAD_CONFIG_LOG_MLE 118 * 119 * Define to enable MLE logging. 120 * 121 */ 122 #ifndef OPENTHREAD_CONFIG_LOG_MLE 123 #define OPENTHREAD_CONFIG_LOG_MLE 1 124 #endif 125 126 /** 127 * @def OPENTHREAD_CONFIG_LOG_MESHCOP 128 * 129 * Define to enable MeshCoP logging. 130 * 131 */ 132 #ifndef OPENTHREAD_CONFIG_LOG_MESHCOP 133 #define OPENTHREAD_CONFIG_LOG_MESHCOP 1 134 #endif 135 136 /** 137 * @def OPENTHREAD_CONFIG_LOG_ARP 138 * 139 * Define to enable EID-to-RLOC map logging. 140 * 141 */ 142 #ifndef OPENTHREAD_CONFIG_LOG_ARP 143 #define OPENTHREAD_CONFIG_LOG_ARP 1 144 #endif 145 146 /** 147 * @def OPENTHREAD_CONFIG_LOG_NETDATA 148 * 149 * Define to enable Network Data logging. 150 * 151 */ 152 #ifndef OPENTHREAD_CONFIG_LOG_NETDATA 153 #define OPENTHREAD_CONFIG_LOG_NETDATA 1 154 #endif 155 156 /** 157 * @def OPENTHREAD_CONFIG_LOG_ICMP 158 * 159 * Define to enable ICMPv6 logging. 160 * 161 */ 162 #ifndef OPENTHREAD_CONFIG_LOG_ICMP 163 #define OPENTHREAD_CONFIG_LOG_ICMP 1 164 #endif 165 166 /** 167 * @def OPENTHREAD_CONFIG_LOG_IP6 168 * 169 * Define to enable IPv6 logging. 170 * 171 */ 172 #ifndef OPENTHREAD_CONFIG_LOG_IP6 173 #define OPENTHREAD_CONFIG_LOG_IP6 1 174 #endif 175 176 /** 177 * @def OPENTHREAD_CONFIG_LOG_TCP 178 * 179 * Define to enable IPv6 logging. 180 * 181 */ 182 #ifndef OPENTHREAD_CONFIG_LOG_TCP 183 #define OPENTHREAD_CONFIG_LOG_TCP 1 184 #endif 185 186 /** 187 * @def OPENTHREAD_CONFIG_LOG_MAC 188 * 189 * Define to enable IEEE 802.15.4 MAC logging. 190 * 191 */ 192 #ifndef OPENTHREAD_CONFIG_LOG_MAC 193 #define OPENTHREAD_CONFIG_LOG_MAC 1 194 #endif 195 196 /** 197 * @def OPENTHREAD_CONFIG_LOG_MEM 198 * 199 * Define to enable memory logging. 200 * 201 */ 202 #ifndef OPENTHREAD_CONFIG_LOG_MEM 203 #define OPENTHREAD_CONFIG_LOG_MEM 1 204 #endif 205 206 /** 207 * @def OPENTHREAD_CONFIG_LOG_PKT_DUMP 208 * 209 * Define to enable log content of packets. 210 * 211 */ 212 #ifndef OPENTHREAD_CONFIG_LOG_PKT_DUMP 213 #define OPENTHREAD_CONFIG_LOG_PKT_DUMP 1 214 #endif 215 216 /** 217 * @def OPENTHREAD_CONFIG_LOG_NETDIAG 218 * 219 * Define to enable network diagnostic logging. 220 * 221 */ 222 #ifndef OPENTHREAD_CONFIG_LOG_NETDIAG 223 #define OPENTHREAD_CONFIG_LOG_NETDIAG 1 224 #endif 225 226 /** 227 * @def OPENTHREAD_CONFIG_LOG_PLATFORM 228 * 229 * Define to enable platform region logging. 230 * 231 */ 232 #ifndef OPENTHREAD_CONFIG_LOG_PLATFORM 233 #define OPENTHREAD_CONFIG_LOG_PLATFORM 1 234 #endif 235 236 /** 237 * @def OPENTHREAD_CONFIG_LOG_CLI 238 * 239 * Define to enable CLI logging. 240 * 241 */ 242 #ifndef OPENTHREAD_CONFIG_LOG_CLI 243 #define OPENTHREAD_CONFIG_LOG_CLI 1 244 #endif 245 246 /** 247 * @def OPENTHREAD_CONFIG_LOG_COAP 248 * 249 * Define to enable COAP logging. 250 * 251 */ 252 #ifndef OPENTHREAD_CONFIG_LOG_COAP 253 #define OPENTHREAD_CONFIG_LOG_COAP 1 254 #endif 255 256 /** 257 * @def OPENTHREAD_CONFIG_LOG_CORE 258 * 259 * Define to enable OpenThread Core logging. 260 * 261 */ 262 #ifndef OPENTHREAD_CONFIG_LOG_CORE 263 #define OPENTHREAD_CONFIG_LOG_CORE 1 264 #endif 265 266 /** 267 * @def OPENTHREAD_CONFIG_LOG_UTIL 268 * 269 * Define to enable OpenThread Utility module logging. 270 * 271 */ 272 #ifndef OPENTHREAD_CONFIG_LOG_UTIL 273 #define OPENTHREAD_CONFIG_LOG_UTIL 1 274 #endif 275 276 /** 277 * @def OPENTHREAD_CONFIG_LOG_BBR 278 * 279 * Note: available since Thread 1.2. 280 * 281 * Define to enable Backbone Router (BBR) region logging. 282 * 283 */ 284 #ifndef OPENTHREAD_CONFIG_LOG_BBR 285 #define OPENTHREAD_CONFIG_LOG_BBR 1 286 #endif 287 288 /** 289 * @def OPENTHREAD_CONFIG_LOG_MLR 290 * 291 * Note: available since Thread 1.2. 292 * 293 * Define to enable Multicast Listener Registration (MLR) region logging. 294 * 295 */ 296 #ifndef OPENTHREAD_CONFIG_LOG_MLR 297 #define OPENTHREAD_CONFIG_LOG_MLR 1 298 #endif 299 300 /** 301 * @def OPENTHREAD_CONFIG_LOG_DUA 302 * 303 * Note: available since Thread 1.2. 304 * 305 * Define to enable Domain Unicast Address (DUA) region logging. 306 * 307 */ 308 #ifndef OPENTHREAD_CONFIG_LOG_DUA 309 #define OPENTHREAD_CONFIG_LOG_DUA 1 310 #endif 311 312 /** 313 * @def OPENTHREAD_CONFIG_LOG_BR 314 * 315 * Define to Border Router (BR) region logging. 316 * 317 */ 318 #ifndef OPENTHREAD_CONFIG_LOG_BR 319 #define OPENTHREAD_CONFIG_LOG_BR 1 320 #endif 321 322 /** 323 * @def OPENTHREAD_CONFIG_LOG_SRP 324 * 325 * Define to enable Service Registration Protocol (SRP) region logging. 326 * 327 */ 328 #ifndef OPENTHREAD_CONFIG_LOG_SRP 329 #define OPENTHREAD_CONFIG_LOG_SRP 1 330 #endif 331 332 /** 333 * @def OPENTHREAD_CONFIG_LOG_DNS 334 * 335 * Define to enable DNS region logging. 336 * 337 */ 338 #ifndef OPENTHREAD_CONFIG_LOG_DNS 339 #define OPENTHREAD_CONFIG_LOG_DNS 1 340 #endif 341 342 /** 343 * @def OPENTHREAD_CONFIG_LOG_PREPEND_LEVEL 344 * 345 * Define to prepend the log level to all log messages. 346 * 347 */ 348 #ifndef OPENTHREAD_CONFIG_LOG_PREPEND_LEVEL 349 #define OPENTHREAD_CONFIG_LOG_PREPEND_LEVEL 1 350 #endif 351 352 /** 353 * @def OPENTHREAD_CONFIG_LOG_PREPEND_REGION 354 * 355 * Define to prepend the log region to all log messages. 356 * 357 */ 358 #ifndef OPENTHREAD_CONFIG_LOG_PREPEND_REGION 359 #define OPENTHREAD_CONFIG_LOG_PREPEND_REGION 1 360 #endif 361 362 /** 363 * @def OPENTHREAD_CONFIG_LOG_SUFFIX 364 * 365 * Define suffix to append at the end of logs. 366 * 367 */ 368 #ifndef OPENTHREAD_CONFIG_LOG_SUFFIX 369 #define OPENTHREAD_CONFIG_LOG_SUFFIX "" 370 #endif 371 372 /** 373 * @def OPENTHREAD_CONFIG_LOG_SRC_DST_IP_ADDRESSES 374 * 375 * If defined as 1 when IPv6 message info is logged in mesh-forwarder, the source and destination IPv6 addresses of 376 * messages are also included. 377 * 378 */ 379 #ifndef OPENTHREAD_CONFIG_LOG_SRC_DST_IP_ADDRESSES 380 #define OPENTHREAD_CONFIG_LOG_SRC_DST_IP_ADDRESSES 1 381 #endif 382 383 /** 384 * @def OPENTHREAD_CONFIG_LOG_DEFINE_AS_MACRO_ONLY 385 * 386 * Set to 1 to require all the logging related definition to user macro only (up to the call to the platform log API). 387 * Otherwise the logging implementation uses functions (which is preferred and recommended model). 388 * 389 * This is intended for special platform requirements where the logging needs to be defined a macro (e.g., for log 390 * tokenization or similar features). 391 * 392 */ 393 #ifndef OPENTHREAD_CONFIG_LOG_DEFINE_AS_MACRO_ONLY 394 #define OPENTHREAD_CONFIG_LOG_DEFINE_AS_MACRO_ONLY 0 395 #endif 396 397 /** 398 * @def OPENTHREAD_CONFIG_PLAT_LOG_MACRO_NAME 399 * 400 * Defines the name of macro used for logging inside OpenThread, by default it is set to `otPlatLog()`. This is used 401 * and applicable only when `OPENTHREAD_CONFIG_LOG_DEFINE_AS_MACRO_ONLY` is set to 1. 402 * 403 */ 404 #ifndef OPENTHREAD_CONFIG_PLAT_LOG_MACRO_NAME 405 #define OPENTHREAD_CONFIG_PLAT_LOG_MACRO_NAME otPlatLog 406 #endif 407 408 /** 409 * @def OPENTHREAD_CONFIG_LOG_MAX_SIZE 410 * 411 * The maximum log string size (number of chars). 412 * 413 */ 414 #ifndef OPENTHREAD_CONFIG_LOG_MAX_SIZE 415 #define OPENTHREAD_CONFIG_LOG_MAX_SIZE 150 416 #endif 417 418 #endif // CONFIG_LOGGING_H_ 419