A Discrete-Event Network Simulator
Home
Tutorials ▼
English
Documentation ▼
Installation
Manual
Models
Contributing
Wiki
Development ▼
API Docs
Issue Tracker
Merge Requests
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
* SPDX-License-Identifier: GPL-2.0-only
5
*
6
* Author: Andrey Mazo <ahippo@yandex.com>
7
*/
8
9
/**
10
* \file
11
* \ingroup logging
12
* Definition of empty logging macros and the NS_LOG_NOOP_INTERNAL macro.
13
*/
14
15
#ifndef NS3_LOG_MACROS_DISABLED_H
16
#define NS3_LOG_MACROS_DISABLED_H
17
18
#ifndef NS3_LOG_ENABLE
19
/*
20
Implementation Note:
21
22
std::clog << msg
23
This expression is required for forms like NS_LOG_LOGIC (... << std::endl ...)
24
25
26
ns3::ParameterLogger (std::clog) << msg
27
This expression is required for NS_LOG_FUNCTION (... << vector ...)
28
29
IMO ParameterLogger should work for both cases, but it fails
30
with the error:
31
32
note: in expansion of macro NS_LOG_LOGIC (std::endl...
33
error: no match for operator<< (operand types are ns3::ParameterLogger
34
and <unresolved overloaded function type>)
35
36
note: candidate: template<class T> ns3::ParameterLogger&
37
ns3::ParameterLogger::operator<<(T)
38
note: template argument deduction/substitution failed
39
note: couldn't deduce template parameter T
40
41
Note that std::endl is templated manipulator function, which needs the
42
target stream to resolve it's own template parameters. The compiler
43
should deduce this from the ParameterLogger::operator<< <T> ()
44
implementation, but evidently fails to do so.
45
46
*/
47
48
/**
49
* \ingroup logging
50
* Empty logging macro implementation, used when logging is disabled.
51
*/
52
#define NS_LOG_NOOP_INTERNAL(msg) \
53
do \
54
if (false) \
55
{ \
56
std::clog << msg; \
57
} \
58
while (false)
59
60
#define NS_LOG(level, msg) NS_LOG_NOOP_INTERNAL(msg)
61
62
#define NS_LOG_FUNCTION_NOARGS()
63
64
/**
65
* \ingroup logging
66
* Empty logging macro implementation, used when logging is disabled.
67
*/
68
#define NS_LOG_NOOP_FUNC_INTERNAL(msg) \
69
do \
70
if (false) \
71
{ \
72
ns3::ParameterLogger(std::clog) << msg; \
73
} \
74
while (false)
75
76
#define NS_LOG_FUNCTION(parameters) NS_LOG_NOOP_FUNC_INTERNAL(parameters)
77
78
#define NS_LOG_UNCOND(msg) NS_LOG_NOOP_INTERNAL(msg)
79
80
#endif
/* !NS3_LOG_ENABLE */
81
82
#endif
/* NS3_LOG_MACROS_DISABLED_H */
src
core
model
log-macros-disabled.h
Generated on Fri Oct 11 2024 18:20:40 for ns-3 by
1.11.0