A Discrete-Event Network Simulator
Home
Tutorials ▼
English
Docs ▼
Wiki
Manual
Models
Develop ▼
API
Bugs
API
log-macros-enabled.h
Go to the documentation of this file.
1
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2
/*
3
* Copyright (c) 2006,2007 INRIA
4
*
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
7
* published by the Free Software Foundation;
8
*
9
* This program is distributed in the hope that it will be useful,
10
* but WITHOUT ANY WARRANTY; without even the implied warranty of
11
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12
* GNU General Public License for more details.
13
*
14
* You should have received a copy of the GNU General Public License
15
* along with this program; if not, write to the Free Software
16
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17
*
18
* Author: Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
19
*/
20
21
#ifndef NS3_LOG_MACROS_ENABLED_H
22
#define NS3_LOG_MACROS_ENABLED_H
23
30
#ifdef NS3_LOG_ENABLE
31
32
39
#define NS_LOG_APPEND_TIME_PREFIX \
40
if (g_log.IsEnabled (ns3::LOG_PREFIX_TIME)) \
41
{ \
42
ns3::TimePrinter printer = ns3::LogGetTimePrinter (); \
43
if (printer != 0) \
44
{ \
45
(*printer)(std::clog); \
46
std::clog << " "; \
47
} \
48
}
49
56
#define NS_LOG_APPEND_NODE_PREFIX \
57
if (g_log.IsEnabled (ns3::LOG_PREFIX_NODE)) \
58
{ \
59
ns3::NodePrinter printer = ns3::LogGetNodePrinter (); \
60
if (printer != 0) \
61
{ \
62
(*printer)(std::clog); \
63
std::clog << " "; \
64
} \
65
}
66
73
#define NS_LOG_APPEND_FUNC_PREFIX \
74
if (g_log.IsEnabled (ns3::LOG_PREFIX_FUNC)) \
75
{ \
76
std::clog << g_log.Name () << ":" \
77
<< __FUNCTION__ << "(): "; \
78
} \
79
80
86
#define NS_LOG_APPEND_LEVEL_PREFIX(level) \
87
if (g_log.IsEnabled (ns3::LOG_PREFIX_LEVEL)) \
88
{ \
89
std::clog << "[" << g_log.GetLevelLabel (level) << "] "; \
90
} \
91
92
93
#ifndef NS_LOG_APPEND_CONTEXT
94
111
#define NS_LOG_APPEND_CONTEXT
112
#endif
/* NS_LOG_APPEND_CONTEXT */
113
114
115
#ifndef NS_LOG_CONDITION
116
130
#define NS_LOG_CONDITION
131
#endif
132
152
#define NS_LOG(level, msg) \
153
NS_LOG_CONDITION \
154
do { \
155
if (g_log.IsEnabled (level)) \
156
{ \
157
NS_LOG_APPEND_TIME_PREFIX; \
158
NS_LOG_APPEND_NODE_PREFIX; \
159
NS_LOG_APPEND_CONTEXT; \
160
NS_LOG_APPEND_FUNC_PREFIX; \
161
NS_LOG_APPEND_LEVEL_PREFIX (level); \
162
std::clog << msg << std::endl; \
163
} \
164
} while (false)
165
174
#define NS_LOG_FUNCTION_NOARGS() \
175
NS_LOG_CONDITION \
176
do { \
177
if (g_log.IsEnabled (ns3::LOG_FUNCTION)) \
178
{ \
179
NS_LOG_APPEND_TIME_PREFIX; \
180
NS_LOG_APPEND_NODE_PREFIX; \
181
NS_LOG_APPEND_CONTEXT; \
182
std::clog << g_log.Name () << ":" \
183
<< __FUNCTION__ << "()" << std::endl; \
184
} \
185
} while (false)
186
187
209
#define NS_LOG_FUNCTION(parameters) \
210
NS_LOG_CONDITION \
211
do \
212
{ \
213
if (g_log.IsEnabled (ns3::LOG_FUNCTION)) \
214
{ \
215
NS_LOG_APPEND_TIME_PREFIX; \
216
NS_LOG_APPEND_NODE_PREFIX; \
217
NS_LOG_APPEND_CONTEXT; \
218
std::clog << g_log.Name () << ":" \
219
<< __FUNCTION__ << "("; \
220
ns3::ParameterLogger (std::clog) << parameters; \
221
std::clog << ")" << std::endl; \
222
} \
223
} \
224
while (false)
225
226
234
#define NS_LOG_UNCOND(msg) \
235
NS_LOG_CONDITION \
236
do { \
237
std::clog << msg << std::endl; \
238
} while (false)
239
240
241
#endif
/* NS3_LOG_ENABLE */
242
243
#endif
/* NS3_LOG_MACROS_ENABLED_H */
src
core
model
log-macros-enabled.h
Generated on Sun Jun 28 2020 12:04:35 for ns-3 by
1.8.14