LEFT | RIGHT |
1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ | 1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ |
2 /* | 2 /* |
3 * Copyright (c) 2006,2007 INRIA | 3 * Copyright (c) 2006,2007 INRIA |
4 * | 4 * |
5 * This program is free software; you can redistribute it and/or modify | 5 * This program is free software; you can redistribute it and/or modify |
6 * it under the terms of the GNU General Public License version 2 as | 6 * it under the terms of the GNU General Public License version 2 as |
7 * published by the Free Software Foundation; | 7 * published by the Free Software Foundation; |
8 * | 8 * |
9 * This program is distributed in the hope that it will be useful, | 9 * This program is distributed in the hope that it will be useful, |
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of | 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
63 std::clog << " "; \ | 63 std::clog << " "; \ |
64 } \ | 64 } \ |
65 } | 65 } |
66 | 66 |
67 /** | 67 /** |
68 * \ingroup logging | 68 * \ingroup logging |
69 * Append the function name to a log message. | 69 * Append the function name to a log message. |
70 * \internal | 70 * \internal |
71 * Logging implementation macro; should not be called directly. | 71 * Logging implementation macro; should not be called directly. |
72 */ | 72 */ |
73 #ifndef _WIN32 | |
74 #define NS_LOG_APPEND_FUNC_PREFIX \ | 73 #define NS_LOG_APPEND_FUNC_PREFIX \ |
75 if (g_log.IsEnabled (ns3::LOG_PREFIX_FUNC)) \ | 74 if (g_log.IsEnabled (ns3::LOG_PREFIX_FUNC)) \ |
76 { \ | 75 { \ |
77 std::clog << g_log.Name () << ":" << \ | 76 std::clog << g_log.Name () << ":" << \ |
78 __FUNCTION__ << "(): "; \ | |
79 } \ | |
80 | |
81 #else | |
82 #define NS_LOG_APPEND_FUNC_PREFIX \ | |
83 if (g_log.IsEnabled (ns3::LOG_PREFIX_FUNC)) \ | |
84 { \ | |
85 std::clog << g_log.Name () << ":" << \ | |
86 __func__ << "(): "; \ | 77 __func__ << "(): "; \ |
87 } \ | 78 } \ |
88 | |
89 #endif | |
90 | 79 |
91 /** | 80 /** |
92 * \ingroup logging | 81 * \ingroup logging |
93 * Append the log severity level to a log message. | 82 * Append the log severity level to a log message. |
94 * \internal | 83 * \internal |
95 * Logging implementation macro; should not be called directly. | 84 * Logging implementation macro; should not be called directly. |
96 */ | 85 */ |
97 #define NS_LOG_APPEND_LEVEL_PREFIX(level) \ | 86 #define NS_LOG_APPEND_LEVEL_PREFIX(level) \ |
98 if (g_log.IsEnabled (ns3::LOG_PREFIX_LEVEL)) \ | 87 if (g_log.IsEnabled (ns3::LOG_PREFIX_LEVEL)) \ |
99 { \ | 88 { \ |
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
177 while (false) | 166 while (false) |
178 | 167 |
179 /** | 168 /** |
180 * \ingroup logging | 169 * \ingroup logging |
181 * | 170 * |
182 * Output the name of the function. | 171 * Output the name of the function. |
183 * | 172 * |
184 * This should be used only in static functions; most member functions | 173 * This should be used only in static functions; most member functions |
185 * should instead use NS_LOG_FUNCTION(). | 174 * should instead use NS_LOG_FUNCTION(). |
186 */ | 175 */ |
187 #ifndef _WIN32 | |
188 #define NS_LOG_FUNCTION_NOARGS() \ | |
189 NS_LOG_CONDITION \ | |
190 do \ | |
191 { \ | |
192 if (g_log.IsEnabled (ns3::LOG_FUNCTION)) \ | |
193 { \ | |
194 NS_LOG_APPEND_TIME_PREFIX; \ | |
195 NS_LOG_APPEND_NODE_PREFIX; \ | |
196 NS_LOG_APPEND_CONTEXT; \ | |
197 std::clog << g_log.Name () << ":" \ | |
198 << __FUNCTION__ << "()" << std::endl; \ | |
199 } \ | |
200 } \ | |
201 while (false) | |
202 | |
203 #else | |
204 #define NS_LOG_FUNCTION_NOARGS() \ | 176 #define NS_LOG_FUNCTION_NOARGS() \ |
205 NS_LOG_CONDITION \ | 177 NS_LOG_CONDITION \ |
206 do \ | 178 do \ |
207 { \ | 179 { \ |
208 if (g_log.IsEnabled (ns3::LOG_FUNCTION)) \ | 180 if (g_log.IsEnabled (ns3::LOG_FUNCTION)) \ |
209 { \ | 181 { \ |
210 NS_LOG_APPEND_TIME_PREFIX; \ | 182 NS_LOG_APPEND_TIME_PREFIX; \ |
211 NS_LOG_APPEND_NODE_PREFIX; \ | 183 NS_LOG_APPEND_NODE_PREFIX; \ |
212 NS_LOG_APPEND_CONTEXT; \ | 184 NS_LOG_APPEND_CONTEXT; \ |
213 std::clog << g_log.Name () << ":" \ | 185 std::clog << g_log.Name () << ":" \ |
214 << __func__ << "()" << std::endl; \ | 186 << __func__ << "()" << std::endl; \ |
215 } \ | 187 } \ |
216 } \ | 188 } \ |
217 while (false) | 189 while (false) |
218 #endif | |
219 | 190 |
220 /** | 191 /** |
221 * \ingroup logging | 192 * \ingroup logging |
222 * | 193 * |
223 * If log level LOG_FUNCTION is enabled, this macro will output | 194 * If log level LOG_FUNCTION is enabled, this macro will output |
224 * all input parameters separated by ", ". | 195 * all input parameters separated by ", ". |
225 * | 196 * |
226 * Typical usage looks like: | 197 * Typical usage looks like: |
227 * \code | 198 * \code |
228 * NS_LOG_FUNCTION (aNumber<<anotherNumber); | 199 * NS_LOG_FUNCTION (aNumber<<anotherNumber); |
229 * \endcode | 200 * \endcode |
230 * And the output will look like: | 201 * And the output will look like: |
231 * \code | 202 * \code |
232 * Component:Function (aNumber, anotherNumber) | 203 * Component:Function (aNumber, anotherNumber) |
233 * \endcode | 204 * \endcode |
234 * | 205 * |
235 * To facilitate function tracing, most functions should begin with | 206 * To facilitate function tracing, most functions should begin with |
236 * (at least) NS_LOG_FUNCTION(this). Static functions should use | 207 * (at least) NS_LOG_FUNCTION(this). Static functions should use |
237 * NS_LOG_FUNCTION_NOARGS() instead. | 208 * NS_LOG_FUNCTION_NOARGS() instead. |
238 * | 209 * |
239 * \param [in] parameters The parameters to output. | 210 * \param [in] parameters The parameters to output. |
240 */ | 211 */ |
241 #ifndef _WIN32 | |
242 #define NS_LOG_FUNCTION(parameters) \ | |
243 NS_LOG_CONDITION \ | |
244 do \ | |
245 { \ | |
246 if (g_log.IsEnabled (ns3::LOG_FUNCTION)) \ | |
247 { \ | |
248 NS_LOG_APPEND_TIME_PREFIX; \ | |
249 NS_LOG_APPEND_NODE_PREFIX; \ | |
250 NS_LOG_APPEND_CONTEXT; \ | |
251 std::clog << g_log.Name () << ":" \ | |
252 << __FUNCTION__ << "("; \ | |
253 ns3::ParameterLogger (std::clog) << parameters; \ | |
254 std::clog << ")" << std::endl; \ | |
255 } \ | |
256 } \ | |
257 while (false) | |
258 #else | |
259 #define NS_LOG_FUNCTION(parameters) \ | 212 #define NS_LOG_FUNCTION(parameters) \ |
260 NS_LOG_CONDITION \ | 213 NS_LOG_CONDITION \ |
261 do \ | 214 do \ |
262 { \ | 215 { \ |
263 if (g_log.IsEnabled (ns3::LOG_FUNCTION)) \ | 216 if (g_log.IsEnabled (ns3::LOG_FUNCTION)) \ |
264 { \ | 217 { \ |
265 NS_LOG_APPEND_TIME_PREFIX; \ | 218 NS_LOG_APPEND_TIME_PREFIX; \ |
266 NS_LOG_APPEND_NODE_PREFIX; \ | 219 NS_LOG_APPEND_NODE_PREFIX; \ |
267 NS_LOG_APPEND_CONTEXT; \ | 220 NS_LOG_APPEND_CONTEXT; \ |
268 std::clog << g_log.Name () << ":" \ | 221 std::clog << g_log.Name () << ":" \ |
269 << __func__ << "("; \ | 222 << __func__ << "("; \ |
270 ns3::ParameterLogger (std::clog) << parameters; \ | 223 ns3::ParameterLogger (std::clog) << parameters; \ |
271 std::clog << ")" << std::endl; \ | 224 std::clog << ")" << std::endl; \ |
272 } \ | 225 } \ |
273 } \ | 226 } \ |
274 while (false) | 227 while (false) |
275 #endif | |
276 | |
277 | 228 |
278 /** | 229 /** |
279 * \ingroup logging | 230 * \ingroup logging |
280 * | 231 * |
281 * Output the requested message unconditionaly. | 232 * Output the requested message unconditionaly. |
282 * | 233 * |
283 * \param [in] msg The message to log | 234 * \param [in] msg The message to log |
284 */ | 235 */ |
285 #define NS_LOG_UNCOND(msg) \ | 236 #define NS_LOG_UNCOND(msg) \ |
286 NS_LOG_CONDITION \ | 237 NS_LOG_CONDITION \ |
287 do \ | 238 do \ |
288 { \ | 239 { \ |
289 std::clog << msg << std::endl; \ | 240 std::clog << msg << std::endl; \ |
290 } \ | 241 } \ |
291 while (false) | 242 while (false) |
292 | 243 |
293 | 244 |
294 #endif /* NS3_LOG_ENABLE */ | 245 #endif /* NS3_LOG_ENABLE */ |
295 | 246 |
296 #endif /* NS3_LOG_MACROS_ENABLED_H */ | 247 #endif /* NS3_LOG_MACROS_ENABLED_H */ |
LEFT | RIGHT |