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_PKT_DUMP 108 * 109 * Define to enable dump logs (of packets). 110 * 111 */ 112 #ifndef OPENTHREAD_CONFIG_LOG_PKT_DUMP 113 #define OPENTHREAD_CONFIG_LOG_PKT_DUMP 1 114 #endif 115 116 /** 117 * @def OPENTHREAD_CONFIG_LOG_CLI 118 * 119 * Define to enable CLI logging and `otLogCli()` OT function. 120 * 121 */ 122 #ifndef OPENTHREAD_CONFIG_LOG_CLI 123 #define OPENTHREAD_CONFIG_LOG_CLI 1 124 #endif 125 126 /** 127 * @def OPENTHREAD_CONFIG_LOG_PLATFORM 128 * 129 * Define to enable platform logging and `otLog{Level}Plat()` OT functions. 130 * 131 */ 132 #ifndef OPENTHREAD_CONFIG_LOG_PLATFORM 133 #define OPENTHREAD_CONFIG_LOG_PLATFORM 1 134 #endif 135 136 /** 137 * @def OPENTHREAD_CONFIG_LOG_PREPEND_UPTIME 138 * 139 * Define as 1 to prepend the current uptime to all log messages. 140 * 141 */ 142 #ifndef OPENTHREAD_CONFIG_LOG_PREPEND_UPTIME 143 #define OPENTHREAD_CONFIG_LOG_PREPEND_UPTIME 0 144 #endif 145 146 /** 147 * @def OPENTHREAD_CONFIG_LOG_PREPEND_LEVEL 148 * 149 * Define to prepend the log level to all log messages. 150 * 151 */ 152 #ifndef OPENTHREAD_CONFIG_LOG_PREPEND_LEVEL 153 #define OPENTHREAD_CONFIG_LOG_PREPEND_LEVEL 1 154 #endif 155 156 /** 157 * @def OPENTHREAD_CONFIG_LOG_SUFFIX 158 * 159 * Define suffix to append at the end of logs. 160 * 161 */ 162 #ifndef OPENTHREAD_CONFIG_LOG_SUFFIX 163 #define OPENTHREAD_CONFIG_LOG_SUFFIX "" 164 #endif 165 166 /** 167 * @def OPENTHREAD_CONFIG_LOG_SRC_DST_IP_ADDRESSES 168 * 169 * If defined as 1 when IPv6 message info is logged in mesh-forwarder, the source and destination IPv6 addresses of 170 * messages are also included. 171 * 172 */ 173 #ifndef OPENTHREAD_CONFIG_LOG_SRC_DST_IP_ADDRESSES 174 #define OPENTHREAD_CONFIG_LOG_SRC_DST_IP_ADDRESSES 1 175 #endif 176 177 /** 178 * @def OPENTHREAD_CONFIG_LOG_MAX_SIZE 179 * 180 * The maximum log string size (number of chars). 181 * 182 */ 183 #ifndef OPENTHREAD_CONFIG_LOG_MAX_SIZE 184 #define OPENTHREAD_CONFIG_LOG_MAX_SIZE 150 185 #endif 186 187 #endif // CONFIG_LOGGING_H_ 188