A Discrete-Event Network Simulator
API
Loading...
Searching...
No Matches
log-macros-disabled.h
Go to the documentation of this file.
1/*
2 * Copyright (c) 2014 Andrey Mazo
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License version 2 as
6 * published by the Free Software Foundation;
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program; if not, write to the Free Software
15 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
16 *
17 * Author: Andrey Mazo <ahippo@yandex.com>
18 */
19
26#ifndef NS3_LOG_MACROS_DISABLED_H
27#define NS3_LOG_MACROS_DISABLED_H
28
29#ifndef NS3_LOG_ENABLE
30/*
31 Implementation Note:
32
33 std::clog << msg
34 This expression is required for forms like NS_LOG_LOGIC (... << std::endl ...)
35
36
37 ns3::ParameterLogger (std::clog) << msg
38 This expression is required for NS_LOG_FUNCTION (... << vector ...)
39
40 IMO ParameterLogger should work for both cases, but it fails
41 with the error:
42
43 note: in expansion of macro NS_LOG_LOGIC (std::endl...
44 error: no match for operator<< (operand types are ns3::ParameterLogger
45 and <unresolved overloaded function type>)
46
47 note: candidate: template<class T> ns3::ParameterLogger&
48 ns3::ParameterLogger::operator<<(T)
49 note: template argument deduction/substitution failed
50 note: couldn't deduce template parameter T
51
52 Note that std::endl is templated manipulator function, which needs the
53 target stream to resolve it's own template parameters. The compiler
54 should deduce this from the ParameterLogger::operator<< <T> ()
55 implementation, but evidently fails to do so.
56
57*/
58
63#define NS_LOG_NOOP_INTERNAL(msg) \
64 do \
65 if (false) \
66 { \
67 std::clog << msg; \
68 } \
69 while (false)
70
71#define NS_LOG(level, msg) NS_LOG_NOOP_INTERNAL(msg)
72
73#define NS_LOG_FUNCTION_NOARGS()
74
79#define NS_LOG_NOOP_FUNC_INTERNAL(msg) \
80 do \
81 if (false) \
82 { \
83 ns3::ParameterLogger(std::clog) << msg; \
84 } \
85 while (false)
86
87#define NS_LOG_FUNCTION(parameters) NS_LOG_NOOP_FUNC_INTERNAL(parameters)
88
89#define NS_LOG_UNCOND(msg) NS_LOG_NOOP_INTERNAL(msg)
90
91#endif /* !NS3_LOG_ENABLE */
92
93#endif /* NS3_LOG_MACROS_DISABLED_H */