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