• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 #ifndef CONFIG_LOGGING_H_
35 #define CONFIG_LOGGING_H_
36 
37 /**
38  * @addtogroup config-logging
39  *
40  * @brief
41  *   This module includes configuration variables for the Logging service.
42  *
43  * @{
44  */
45 
46 /**
47  * @def OPENTHREAD_CONFIG_LOG_OUTPUT
48  *
49  * Selects if, and where the LOG output goes to.
50  *
51  * There are several options available
52  * - @sa OPENTHREAD_CONFIG_LOG_OUTPUT_NONE
53  * - @sa OPENTHREAD_CONFIG_LOG_OUTPUT_DEBUG_UART
54  * - @sa OPENTHREAD_CONFIG_LOG_OUTPUT_APP
55  * - @sa OPENTHREAD_CONFIG_LOG_OUTPUT_PLATFORM_DEFINED
56  * - and others
57  *
58  * Note:
59  *
60  * 1) Because the default is: OPENTHREAD_CONFIG_LOG_OUTPUT_PLATFORM_DEFINED
61  *    The platform is expected to provide at least a stub for `otPlatLog()`.
62  *
63  * 2) This is effectively an ENUM so it can be if/else/endif at compile time.
64  */
65 #ifndef OPENTHREAD_CONFIG_LOG_OUTPUT
66 #define OPENTHREAD_CONFIG_LOG_OUTPUT OPENTHREAD_CONFIG_LOG_OUTPUT_PLATFORM_DEFINED
67 #endif
68 
69 /** Log output goes to the bit bucket (disabled) */
70 #define OPENTHREAD_CONFIG_LOG_OUTPUT_NONE 0
71 /** Log output goes to the debug uart - requires OPENTHREAD_CONFIG_ENABLE_DEBUG_UART to be enabled */
72 #define OPENTHREAD_CONFIG_LOG_OUTPUT_DEBUG_UART 1
73 /** Log output goes to the "application" provided otPlatLog() in NCP and CLI code */
74 #define OPENTHREAD_CONFIG_LOG_OUTPUT_APP 2
75 /** Log output is handled by a platform defined function */
76 #define OPENTHREAD_CONFIG_LOG_OUTPUT_PLATFORM_DEFINED 3
77 
78 /**
79  * @def OPENTHREAD_CONFIG_LOG_LEVEL
80  *
81  * The log level (used at compile time). If `OPENTHREAD_CONFIG_LOG_LEVEL_DYNAMIC_ENABLE` is set, this defines the most
82  * verbose log level possible. See `OPENTHREAD_CONFIG_LOG_LEVEL_INIT` to set the initial log level.
83  */
84 #ifndef OPENTHREAD_CONFIG_LOG_LEVEL
85 #define OPENTHREAD_CONFIG_LOG_LEVEL OT_LOG_LEVEL_CRIT
86 #endif
87 
88 /**
89  * @def OPENTHREAD_CONFIG_LOG_LEVEL_DYNAMIC_ENABLE
90  *
91  * Define as 1 to enable dynamic log level control.
92  *
93  * Note that the OPENTHREAD_CONFIG_LOG_LEVEL determines the log level at
94  * compile time. The dynamic log level control (if enabled) only allows
95  * decreasing the log level from the compile time value.
96  */
97 #ifndef OPENTHREAD_CONFIG_LOG_LEVEL_DYNAMIC_ENABLE
98 #define OPENTHREAD_CONFIG_LOG_LEVEL_DYNAMIC_ENABLE 0
99 #endif
100 
101 /**
102  * @def OPENTHREAD_CONFIG_LOG_LEVEL_INIT
103  *
104  * The initial log level used when OpenThread is initialized. See
105  * `OPENTHREAD_CONFIG_LOG_LEVEL_DYNAMIC_ENABLE`.
106  */
107 #ifndef OPENTHREAD_CONFIG_LOG_LEVEL_INIT
108 #define OPENTHREAD_CONFIG_LOG_LEVEL_INIT OPENTHREAD_CONFIG_LOG_LEVEL
109 #endif
110 
111 /**
112  * @def OPENTHREAD_CONFIG_LOG_PKT_DUMP
113  *
114  * Define to enable dump logs (of packets).
115  */
116 #ifndef OPENTHREAD_CONFIG_LOG_PKT_DUMP
117 #define OPENTHREAD_CONFIG_LOG_PKT_DUMP 1
118 #endif
119 
120 /**
121  * @def OPENTHREAD_CONFIG_LOG_CLI
122  *
123  * Define to enable CLI logging and `otLogCli()` OT function.
124  */
125 #ifndef OPENTHREAD_CONFIG_LOG_CLI
126 #define OPENTHREAD_CONFIG_LOG_CLI 1
127 #endif
128 
129 /**
130  * @def OPENTHREAD_CONFIG_LOG_PLATFORM
131  *
132  * Define to enable platform logging and `otLog{Level}Plat()` OT functions.
133  */
134 #ifndef OPENTHREAD_CONFIG_LOG_PLATFORM
135 #define OPENTHREAD_CONFIG_LOG_PLATFORM 1
136 #endif
137 
138 /**
139  * @def OPENTHREAD_CONFIG_LOG_PREPEND_UPTIME
140  *
141  * Define as 1 to prepend the current uptime to all log messages.
142  */
143 #ifndef OPENTHREAD_CONFIG_LOG_PREPEND_UPTIME
144 #define OPENTHREAD_CONFIG_LOG_PREPEND_UPTIME 0
145 #endif
146 
147 /**
148  * @def OPENTHREAD_CONFIG_LOG_PREPEND_LEVEL
149  *
150  * Define to prepend the log level to all log messages.
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 #ifndef OPENTHREAD_CONFIG_LOG_SUFFIX
162 #define OPENTHREAD_CONFIG_LOG_SUFFIX ""
163 #endif
164 
165 /**
166  * @def OPENTHREAD_CONFIG_LOG_SRC_DST_IP_ADDRESSES
167  *
168  * If defined as 1 when IPv6 message info is logged in mesh-forwarder, the source and destination IPv6 addresses of
169  * messages are also included.
170  */
171 #ifndef OPENTHREAD_CONFIG_LOG_SRC_DST_IP_ADDRESSES
172 #define OPENTHREAD_CONFIG_LOG_SRC_DST_IP_ADDRESSES 1
173 #endif
174 
175 /**
176  * @def OPENTHREAD_CONFIG_LOG_MAX_SIZE
177  *
178  * The maximum log string size (number of chars).
179  */
180 #ifndef OPENTHREAD_CONFIG_LOG_MAX_SIZE
181 #define OPENTHREAD_CONFIG_LOG_MAX_SIZE 150
182 #endif
183 
184 /**
185  * @}
186  */
187 
188 #endif // CONFIG_LOGGING_H_
189