32 * send information out on screen. All logging messages |
32 * send information out on screen. All logging messages |
33 * are disabled by default. To enable selected logging |
33 * are disabled by default. To enable selected logging |
34 * messages, use the ns3::LogComponentEnable |
34 * messages, use the ns3::LogComponentEnable |
35 * function or use the NS_LOG environment variable and |
35 * function or use the NS_LOG environment variable and |
36 * ns3::LogComponentEnableEnvVar |
36 * ns3::LogComponentEnableEnvVar |
|
37 * |
|
38 * Use the environment variable NS_LOG to define a ';'-separated list of |
|
39 * logging components to enable. For example, NS_LOG=a;b;c;DAFD;GH |
|
40 * would enable the components 'a', 'b', 'c', 'DAFD', and, 'GH'. |
|
41 * NS_LOG=* will enable all available log components. |
|
42 * |
|
43 * For each component, the "debug" log level is enabled by default |
|
44 * but more components can be enabled selectively with the following |
|
45 * syntax: NS_LOG='Component1=func|param|warn;Component2=error|debug' |
|
46 * This example would enable the 'func', 'param', and 'warn' log |
|
47 * levels for 'Component1' and the 'error' and 'debug' log levels |
|
48 * for 'Component2'. The wildcard can be used here as well. For example |
|
49 * NS_LOG='*=level_all|prefix' would enable all log levels and prefix all |
|
50 * prints with the component and function names. |
|
51 * |
37 */ |
52 */ |
38 |
53 |
39 /** |
54 /** |
40 * \ingroup logging |
55 * \ingroup logging |
41 * \param name a string |
56 * \param name a string |
178 |
193 |
179 #endif |
194 #endif |
180 |
195 |
181 #ifdef NS3_LOG_ENABLE |
196 #ifdef NS3_LOG_ENABLE |
182 /** |
197 /** |
183 * \brief Enable the logging output based on an environment variable. |
|
184 * |
|
185 * Use the environment variable NS_LOG to define a ';'-separated list of |
|
186 * logging components to enable. For example, NS_LOG=a;b;c;DAFD;GH |
|
187 * would enable the components 'a', 'b', 'c', 'DAFD', and, 'GH'. |
|
188 * NS_LOG=* will enable all available log components. |
|
189 * |
|
190 * For each component, the "debug" log level is enabled by default |
|
191 * but more components can be enabled selectively with the following |
|
192 * syntax: NS_LOG='Component1=func|param|warn;Component2=error|debug' |
|
193 * This example would enable the 'func', 'param', and 'warn' log |
|
194 * levels for 'Component1' and the 'error' and 'debug' log levels |
|
195 * for 'Component2'. The wildcard can be used here as well. For example |
|
196 * NS_LOG='*=level_all|prefix' would enable all log levels and prefix all |
|
197 * prints with the component and function names. |
|
198 * |
|
199 * The list of available log components can be printed on stdout |
|
200 * with the NS_LOG=print-list syntax. |
|
201 */ |
|
202 void LogComponentEnableEnvVar (void); |
|
203 |
|
204 /** |
|
205 * \param name a log component name |
198 * \param name a log component name |
206 * \param level a logging level |
199 * \param level a logging level |
207 * \param decorate whether or not to add function names to all logs |
200 * \param decorate whether or not to add function names to all logs |
208 * \ingroup logging |
201 * \ingroup logging |
209 * |
202 * |
220 * |
213 * |
221 * Enable the logging output for all registered log components. |
214 * Enable the logging output for all registered log components. |
222 */ |
215 */ |
223 void LogComponentEnableAll (enum LogLevel level); |
216 void LogComponentEnableAll (enum LogLevel level); |
224 #else |
217 #else |
225 #define LogComponentEnableEnvVar() |
|
226 #define LogComponentEnable(a,b) |
218 #define LogComponentEnable(a,b) |
227 #define LogComponentEnableAll(a) |
219 #define LogComponentEnableAll(a) |
228 #endif |
220 #endif |
229 |
221 |
230 #ifdef NS3_LOG_ENABLE |
222 #ifdef NS3_LOG_ENABLE |
257 |
249 |
258 /** |
250 /** |
259 * \ingroup logging |
251 * \ingroup logging |
260 * |
252 * |
261 * Print the list of logging messages available. |
253 * Print the list of logging messages available. |
262 * The output of this function can be obtained by setting |
|
263 * the NS_LOG environment variable to the special value |
|
264 * 'print-list'. |
|
265 * |
|
266 * For example: NS_LOG=print-list |
|
267 */ |
254 */ |
268 #ifdef NS3_LOG_ENABLE |
255 #ifdef NS3_LOG_ENABLE |
269 void LogComponentPrintList (void); |
256 void LogComponentPrintList (void); |
270 #else |
257 #else |
271 #define LogComponentPrintList() |
258 #define LogComponentPrintList() |
274 #ifdef NS3_LOG_ENABLE |
261 #ifdef NS3_LOG_ENABLE |
275 |
262 |
276 class LogComponent { |
263 class LogComponent { |
277 public: |
264 public: |
278 LogComponent (char const *name); |
265 LogComponent (char const *name); |
|
266 void EnvVarCheck (char const *name); |
279 bool IsEnabled (enum LogLevel level) const; |
267 bool IsEnabled (enum LogLevel level) const; |
280 bool IsNoneEnabled (void) const; |
268 bool IsNoneEnabled (void) const; |
281 void Enable (enum LogLevel level); |
269 void Enable (enum LogLevel level); |
282 void Disable (enum LogLevel level); |
270 void Disable (enum LogLevel level); |
283 bool Decorate (void) const; |
271 bool Decorate (void) const; |