author | Tom Henderson <tomh@tomh.org> |
Thu, 10 Jan 2008 07:31:40 -0800 | |
changeset 2217 | 0b4567d545de |
parent 1830 | 8fead8808f3f |
child 2294 | aa08830477cb |
permissions | -rw-r--r-- |
1498
520bc8457799
log rides along for free
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
1 |
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ |
520bc8457799
log rides along for free
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
2 |
/* |
520bc8457799
log rides along for free
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
3 |
* Copyright (c) 2006,2007 INRIA |
520bc8457799
log rides along for free
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
4 |
* |
520bc8457799
log rides along for free
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
5 |
* This program is free software; you can redistribute it and/or modify |
520bc8457799
log rides along for free
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
6 |
* it under the terms of the GNU General Public License version 2 as |
520bc8457799
log rides along for free
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
7 |
* published by the Free Software Foundation; |
520bc8457799
log rides along for free
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
8 |
* |
520bc8457799
log rides along for free
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
9 |
* This program is distributed in the hope that it will be useful, |
520bc8457799
log rides along for free
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
10 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
520bc8457799
log rides along for free
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
11 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
520bc8457799
log rides along for free
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
12 |
* GNU General Public License for more details. |
520bc8457799
log rides along for free
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
13 |
* |
520bc8457799
log rides along for free
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
14 |
* You should have received a copy of the GNU General Public License |
520bc8457799
log rides along for free
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
15 |
* along with this program; if not, write to the Free Software |
520bc8457799
log rides along for free
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
16 |
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
520bc8457799
log rides along for free
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
17 |
* |
520bc8457799
log rides along for free
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
18 |
* Author: Mathieu Lacage <mathieu.lacage@sophia.inria.fr> |
520bc8457799
log rides along for free
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
19 |
*/ |
1506
3c8b23550e6a
disable log unless debug build
Craig Dowell <craigdo@ee.washington.edu>
parents:
1504
diff
changeset
|
20 |
|
3c8b23550e6a
disable log unless debug build
Craig Dowell <craigdo@ee.washington.edu>
parents:
1504
diff
changeset
|
21 |
#ifndef __LOG_H__ |
3c8b23550e6a
disable log unless debug build
Craig Dowell <craigdo@ee.washington.edu>
parents:
1504
diff
changeset
|
22 |
#define __LOG_H__ |
1498
520bc8457799
log rides along for free
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
23 |
|
520bc8457799
log rides along for free
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
24 |
#include <string> |
520bc8457799
log rides along for free
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
25 |
#include <iostream> |
520bc8457799
log rides along for free
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
26 |
|
520bc8457799
log rides along for free
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
27 |
/** |
2217 | 28 |
* \ingroup core |
1498
520bc8457799
log rides along for free
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
29 |
* \defgroup logging Logging |
520bc8457799
log rides along for free
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
30 |
* \brief Logging functions and macros |
520bc8457799
log rides along for free
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
31 |
* |
520bc8457799
log rides along for free
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
32 |
* LOG functionality: macros which allow developers to |
520bc8457799
log rides along for free
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
33 |
* send information out on screen. All logging messages |
520bc8457799
log rides along for free
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
34 |
* are disabled by default. To enable selected logging |
520bc8457799
log rides along for free
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
35 |
* messages, use the ns3::LogComponentEnable |
1775
5abf6f0d1eca
deal with static constructor problem
Craig Dowell <craigdo@ee.washington.edu>
parents:
1772
diff
changeset
|
36 |
* function or use the NS_LOG environment variable and |
5abf6f0d1eca
deal with static constructor problem
Craig Dowell <craigdo@ee.washington.edu>
parents:
1772
diff
changeset
|
37 |
* ns3::LogComponentEnableEnvVar |
1783
36472385a1cc
NS_LOG parsing changes to address bug 91
Craig Dowell <craigdo@ee.washington.edu>
parents:
1775
diff
changeset
|
38 |
* |
36472385a1cc
NS_LOG parsing changes to address bug 91
Craig Dowell <craigdo@ee.washington.edu>
parents:
1775
diff
changeset
|
39 |
* Use the environment variable NS_LOG to define a ';'-separated list of |
36472385a1cc
NS_LOG parsing changes to address bug 91
Craig Dowell <craigdo@ee.washington.edu>
parents:
1775
diff
changeset
|
40 |
* logging components to enable. For example, NS_LOG=a;b;c;DAFD;GH |
36472385a1cc
NS_LOG parsing changes to address bug 91
Craig Dowell <craigdo@ee.washington.edu>
parents:
1775
diff
changeset
|
41 |
* would enable the components 'a', 'b', 'c', 'DAFD', and, 'GH'. |
36472385a1cc
NS_LOG parsing changes to address bug 91
Craig Dowell <craigdo@ee.washington.edu>
parents:
1775
diff
changeset
|
42 |
* NS_LOG=* will enable all available log components. |
36472385a1cc
NS_LOG parsing changes to address bug 91
Craig Dowell <craigdo@ee.washington.edu>
parents:
1775
diff
changeset
|
43 |
* |
36472385a1cc
NS_LOG parsing changes to address bug 91
Craig Dowell <craigdo@ee.washington.edu>
parents:
1775
diff
changeset
|
44 |
* For each component, the "debug" log level is enabled by default |
36472385a1cc
NS_LOG parsing changes to address bug 91
Craig Dowell <craigdo@ee.washington.edu>
parents:
1775
diff
changeset
|
45 |
* but more components can be enabled selectively with the following |
36472385a1cc
NS_LOG parsing changes to address bug 91
Craig Dowell <craigdo@ee.washington.edu>
parents:
1775
diff
changeset
|
46 |
* syntax: NS_LOG='Component1=func|param|warn;Component2=error|debug' |
36472385a1cc
NS_LOG parsing changes to address bug 91
Craig Dowell <craigdo@ee.washington.edu>
parents:
1775
diff
changeset
|
47 |
* This example would enable the 'func', 'param', and 'warn' log |
36472385a1cc
NS_LOG parsing changes to address bug 91
Craig Dowell <craigdo@ee.washington.edu>
parents:
1775
diff
changeset
|
48 |
* levels for 'Component1' and the 'error' and 'debug' log levels |
36472385a1cc
NS_LOG parsing changes to address bug 91
Craig Dowell <craigdo@ee.washington.edu>
parents:
1775
diff
changeset
|
49 |
* for 'Component2'. The wildcard can be used here as well. For example |
36472385a1cc
NS_LOG parsing changes to address bug 91
Craig Dowell <craigdo@ee.washington.edu>
parents:
1775
diff
changeset
|
50 |
* NS_LOG='*=level_all|prefix' would enable all log levels and prefix all |
36472385a1cc
NS_LOG parsing changes to address bug 91
Craig Dowell <craigdo@ee.washington.edu>
parents:
1775
diff
changeset
|
51 |
* prints with the component and function names. |
36472385a1cc
NS_LOG parsing changes to address bug 91
Craig Dowell <craigdo@ee.washington.edu>
parents:
1775
diff
changeset
|
52 |
* |
1498
520bc8457799
log rides along for free
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
53 |
*/ |
520bc8457799
log rides along for free
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
54 |
|
520bc8457799
log rides along for free
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
55 |
/** |
520bc8457799
log rides along for free
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
56 |
* \ingroup logging |
520bc8457799
log rides along for free
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
57 |
* \param name a string |
520bc8457799
log rides along for free
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
58 |
* |
520bc8457799
log rides along for free
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
59 |
* Define a Log component with a specific name. This macro |
520bc8457799
log rides along for free
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
60 |
* should be used at the top of every file in which you want |
520bc8457799
log rides along for free
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
61 |
* to use the NS_LOG macro. This macro defines a new |
520bc8457799
log rides along for free
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
62 |
* "log component" which can be later selectively enabled |
520bc8457799
log rides along for free
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
63 |
* or disabled with the ns3::LogComponentEnable and |
520bc8457799
log rides along for free
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
64 |
* ns3::LogComponentDisable functions or with the NS_LOG |
520bc8457799
log rides along for free
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
65 |
* environment variable. |
520bc8457799
log rides along for free
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
66 |
*/ |
1506
3c8b23550e6a
disable log unless debug build
Craig Dowell <craigdo@ee.washington.edu>
parents:
1504
diff
changeset
|
67 |
|
3c8b23550e6a
disable log unless debug build
Craig Dowell <craigdo@ee.washington.edu>
parents:
1504
diff
changeset
|
68 |
#ifdef NS3_LOG_ENABLE |
3c8b23550e6a
disable log unless debug build
Craig Dowell <craigdo@ee.washington.edu>
parents:
1504
diff
changeset
|
69 |
|
1498
520bc8457799
log rides along for free
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
70 |
#define NS_LOG_COMPONENT_DEFINE(name) \ |
520bc8457799
log rides along for free
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
71 |
static ns3::LogComponent g_log = ns3::LogComponent (name) |
520bc8457799
log rides along for free
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
72 |
|
1506
3c8b23550e6a
disable log unless debug build
Craig Dowell <craigdo@ee.washington.edu>
parents:
1504
diff
changeset
|
73 |
#else |
3c8b23550e6a
disable log unless debug build
Craig Dowell <craigdo@ee.washington.edu>
parents:
1504
diff
changeset
|
74 |
|
3c8b23550e6a
disable log unless debug build
Craig Dowell <craigdo@ee.washington.edu>
parents:
1504
diff
changeset
|
75 |
#define NS_LOG_COMPONENT_DEFINE(name) |
3c8b23550e6a
disable log unless debug build
Craig Dowell <craigdo@ee.washington.edu>
parents:
1504
diff
changeset
|
76 |
|
3c8b23550e6a
disable log unless debug build
Craig Dowell <craigdo@ee.washington.edu>
parents:
1504
diff
changeset
|
77 |
#endif |
3c8b23550e6a
disable log unless debug build
Craig Dowell <craigdo@ee.washington.edu>
parents:
1504
diff
changeset
|
78 |
|
1828
6ab68edddf45
nicer logging of parameters (bug 79 patch from Gustavo)
Tom Henderson <tomh@tomh.org>
parents:
1795
diff
changeset
|
79 |
|
1498
520bc8457799
log rides along for free
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
80 |
/** |
520bc8457799
log rides along for free
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
81 |
* \ingroup logging |
520bc8457799
log rides along for free
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
82 |
* \param msg message to output |
520bc8457799
log rides along for free
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
83 |
* |
520bc8457799
log rides along for free
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
84 |
* Generate logging output in the "log component" of the |
520bc8457799
log rides along for free
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
85 |
* current file. i.e., every call to NS_LOG from within |
520bc8457799
log rides along for free
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
86 |
* a file implicitely generates out within the component |
520bc8457799
log rides along for free
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
87 |
* defined with the NS_LOG_COMPONENT_DEFINE macro in the |
520bc8457799
log rides along for free
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
88 |
* same file. |
520bc8457799
log rides along for free
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
89 |
*/ |
1506
3c8b23550e6a
disable log unless debug build
Craig Dowell <craigdo@ee.washington.edu>
parents:
1504
diff
changeset
|
90 |
|
3c8b23550e6a
disable log unless debug build
Craig Dowell <craigdo@ee.washington.edu>
parents:
1504
diff
changeset
|
91 |
#ifdef NS3_LOG_ENABLE |
3c8b23550e6a
disable log unless debug build
Craig Dowell <craigdo@ee.washington.edu>
parents:
1504
diff
changeset
|
92 |
|
1828
6ab68edddf45
nicer logging of parameters (bug 79 patch from Gustavo)
Tom Henderson <tomh@tomh.org>
parents:
1795
diff
changeset
|
93 |
|
6ab68edddf45
nicer logging of parameters (bug 79 patch from Gustavo)
Tom Henderson <tomh@tomh.org>
parents:
1795
diff
changeset
|
94 |
namespace ns3 { |
6ab68edddf45
nicer logging of parameters (bug 79 patch from Gustavo)
Tom Henderson <tomh@tomh.org>
parents:
1795
diff
changeset
|
95 |
|
6ab68edddf45
nicer logging of parameters (bug 79 patch from Gustavo)
Tom Henderson <tomh@tomh.org>
parents:
1795
diff
changeset
|
96 |
struct EndParameterListStruct {}; |
6ab68edddf45
nicer logging of parameters (bug 79 patch from Gustavo)
Tom Henderson <tomh@tomh.org>
parents:
1795
diff
changeset
|
97 |
extern EndParameterListStruct EndParameterList; |
6ab68edddf45
nicer logging of parameters (bug 79 patch from Gustavo)
Tom Henderson <tomh@tomh.org>
parents:
1795
diff
changeset
|
98 |
|
6ab68edddf45
nicer logging of parameters (bug 79 patch from Gustavo)
Tom Henderson <tomh@tomh.org>
parents:
1795
diff
changeset
|
99 |
struct ParameterName |
6ab68edddf45
nicer logging of parameters (bug 79 patch from Gustavo)
Tom Henderson <tomh@tomh.org>
parents:
1795
diff
changeset
|
100 |
{ |
6ab68edddf45
nicer logging of parameters (bug 79 patch from Gustavo)
Tom Henderson <tomh@tomh.org>
parents:
1795
diff
changeset
|
101 |
const char *name; |
6ab68edddf45
nicer logging of parameters (bug 79 patch from Gustavo)
Tom Henderson <tomh@tomh.org>
parents:
1795
diff
changeset
|
102 |
ParameterName (const char *name_) : name (name_) {} |
6ab68edddf45
nicer logging of parameters (bug 79 patch from Gustavo)
Tom Henderson <tomh@tomh.org>
parents:
1795
diff
changeset
|
103 |
}; |
6ab68edddf45
nicer logging of parameters (bug 79 patch from Gustavo)
Tom Henderson <tomh@tomh.org>
parents:
1795
diff
changeset
|
104 |
|
6ab68edddf45
nicer logging of parameters (bug 79 patch from Gustavo)
Tom Henderson <tomh@tomh.org>
parents:
1795
diff
changeset
|
105 |
class ParameterLogger : public std::ostream |
6ab68edddf45
nicer logging of parameters (bug 79 patch from Gustavo)
Tom Henderson <tomh@tomh.org>
parents:
1795
diff
changeset
|
106 |
{ |
6ab68edddf45
nicer logging of parameters (bug 79 patch from Gustavo)
Tom Henderson <tomh@tomh.org>
parents:
1795
diff
changeset
|
107 |
int m_itemNumber; |
6ab68edddf45
nicer logging of parameters (bug 79 patch from Gustavo)
Tom Henderson <tomh@tomh.org>
parents:
1795
diff
changeset
|
108 |
const char *m_parameterName; |
6ab68edddf45
nicer logging of parameters (bug 79 patch from Gustavo)
Tom Henderson <tomh@tomh.org>
parents:
1795
diff
changeset
|
109 |
public: |
6ab68edddf45
nicer logging of parameters (bug 79 patch from Gustavo)
Tom Henderson <tomh@tomh.org>
parents:
1795
diff
changeset
|
110 |
ParameterLogger () |
6ab68edddf45
nicer logging of parameters (bug 79 patch from Gustavo)
Tom Henderson <tomh@tomh.org>
parents:
1795
diff
changeset
|
111 |
: m_itemNumber (0) |
6ab68edddf45
nicer logging of parameters (bug 79 patch from Gustavo)
Tom Henderson <tomh@tomh.org>
parents:
1795
diff
changeset
|
112 |
{} |
6ab68edddf45
nicer logging of parameters (bug 79 patch from Gustavo)
Tom Henderson <tomh@tomh.org>
parents:
1795
diff
changeset
|
113 |
|
6ab68edddf45
nicer logging of parameters (bug 79 patch from Gustavo)
Tom Henderson <tomh@tomh.org>
parents:
1795
diff
changeset
|
114 |
template<typename T> |
6ab68edddf45
nicer logging of parameters (bug 79 patch from Gustavo)
Tom Henderson <tomh@tomh.org>
parents:
1795
diff
changeset
|
115 |
ParameterLogger& operator<< (T param) |
6ab68edddf45
nicer logging of parameters (bug 79 patch from Gustavo)
Tom Henderson <tomh@tomh.org>
parents:
1795
diff
changeset
|
116 |
{ |
6ab68edddf45
nicer logging of parameters (bug 79 patch from Gustavo)
Tom Henderson <tomh@tomh.org>
parents:
1795
diff
changeset
|
117 |
switch (m_itemNumber) |
6ab68edddf45
nicer logging of parameters (bug 79 patch from Gustavo)
Tom Henderson <tomh@tomh.org>
parents:
1795
diff
changeset
|
118 |
{ |
6ab68edddf45
nicer logging of parameters (bug 79 patch from Gustavo)
Tom Henderson <tomh@tomh.org>
parents:
1795
diff
changeset
|
119 |
case 0: // first item is actually the function name |
6ab68edddf45
nicer logging of parameters (bug 79 patch from Gustavo)
Tom Henderson <tomh@tomh.org>
parents:
1795
diff
changeset
|
120 |
if (m_parameterName) |
6ab68edddf45
nicer logging of parameters (bug 79 patch from Gustavo)
Tom Henderson <tomh@tomh.org>
parents:
1795
diff
changeset
|
121 |
{ |
6ab68edddf45
nicer logging of parameters (bug 79 patch from Gustavo)
Tom Henderson <tomh@tomh.org>
parents:
1795
diff
changeset
|
122 |
std::clog << m_parameterName << "=" << param; |
6ab68edddf45
nicer logging of parameters (bug 79 patch from Gustavo)
Tom Henderson <tomh@tomh.org>
parents:
1795
diff
changeset
|
123 |
m_parameterName = 0; |
6ab68edddf45
nicer logging of parameters (bug 79 patch from Gustavo)
Tom Henderson <tomh@tomh.org>
parents:
1795
diff
changeset
|
124 |
} |
6ab68edddf45
nicer logging of parameters (bug 79 patch from Gustavo)
Tom Henderson <tomh@tomh.org>
parents:
1795
diff
changeset
|
125 |
else |
6ab68edddf45
nicer logging of parameters (bug 79 patch from Gustavo)
Tom Henderson <tomh@tomh.org>
parents:
1795
diff
changeset
|
126 |
{ |
6ab68edddf45
nicer logging of parameters (bug 79 patch from Gustavo)
Tom Henderson <tomh@tomh.org>
parents:
1795
diff
changeset
|
127 |
std::clog << param; |
6ab68edddf45
nicer logging of parameters (bug 79 patch from Gustavo)
Tom Henderson <tomh@tomh.org>
parents:
1795
diff
changeset
|
128 |
} |
6ab68edddf45
nicer logging of parameters (bug 79 patch from Gustavo)
Tom Henderson <tomh@tomh.org>
parents:
1795
diff
changeset
|
129 |
break; |
6ab68edddf45
nicer logging of parameters (bug 79 patch from Gustavo)
Tom Henderson <tomh@tomh.org>
parents:
1795
diff
changeset
|
130 |
case 1: |
6ab68edddf45
nicer logging of parameters (bug 79 patch from Gustavo)
Tom Henderson <tomh@tomh.org>
parents:
1795
diff
changeset
|
131 |
if (m_parameterName) |
6ab68edddf45
nicer logging of parameters (bug 79 patch from Gustavo)
Tom Henderson <tomh@tomh.org>
parents:
1795
diff
changeset
|
132 |
{ |
6ab68edddf45
nicer logging of parameters (bug 79 patch from Gustavo)
Tom Henderson <tomh@tomh.org>
parents:
1795
diff
changeset
|
133 |
std::clog << ", " << m_parameterName << "=" << param; |
6ab68edddf45
nicer logging of parameters (bug 79 patch from Gustavo)
Tom Henderson <tomh@tomh.org>
parents:
1795
diff
changeset
|
134 |
m_parameterName = 0; |
6ab68edddf45
nicer logging of parameters (bug 79 patch from Gustavo)
Tom Henderson <tomh@tomh.org>
parents:
1795
diff
changeset
|
135 |
} |
6ab68edddf45
nicer logging of parameters (bug 79 patch from Gustavo)
Tom Henderson <tomh@tomh.org>
parents:
1795
diff
changeset
|
136 |
else |
6ab68edddf45
nicer logging of parameters (bug 79 patch from Gustavo)
Tom Henderson <tomh@tomh.org>
parents:
1795
diff
changeset
|
137 |
{ |
6ab68edddf45
nicer logging of parameters (bug 79 patch from Gustavo)
Tom Henderson <tomh@tomh.org>
parents:
1795
diff
changeset
|
138 |
std::clog << ", " << param; |
6ab68edddf45
nicer logging of parameters (bug 79 patch from Gustavo)
Tom Henderson <tomh@tomh.org>
parents:
1795
diff
changeset
|
139 |
} |
6ab68edddf45
nicer logging of parameters (bug 79 patch from Gustavo)
Tom Henderson <tomh@tomh.org>
parents:
1795
diff
changeset
|
140 |
break; |
6ab68edddf45
nicer logging of parameters (bug 79 patch from Gustavo)
Tom Henderson <tomh@tomh.org>
parents:
1795
diff
changeset
|
141 |
default: // parameter following a previous parameter |
6ab68edddf45
nicer logging of parameters (bug 79 patch from Gustavo)
Tom Henderson <tomh@tomh.org>
parents:
1795
diff
changeset
|
142 |
std::clog << ", " << param; |
6ab68edddf45
nicer logging of parameters (bug 79 patch from Gustavo)
Tom Henderson <tomh@tomh.org>
parents:
1795
diff
changeset
|
143 |
break; |
6ab68edddf45
nicer logging of parameters (bug 79 patch from Gustavo)
Tom Henderson <tomh@tomh.org>
parents:
1795
diff
changeset
|
144 |
} |
6ab68edddf45
nicer logging of parameters (bug 79 patch from Gustavo)
Tom Henderson <tomh@tomh.org>
parents:
1795
diff
changeset
|
145 |
m_itemNumber++; |
6ab68edddf45
nicer logging of parameters (bug 79 patch from Gustavo)
Tom Henderson <tomh@tomh.org>
parents:
1795
diff
changeset
|
146 |
return *this; |
6ab68edddf45
nicer logging of parameters (bug 79 patch from Gustavo)
Tom Henderson <tomh@tomh.org>
parents:
1795
diff
changeset
|
147 |
} |
6ab68edddf45
nicer logging of parameters (bug 79 patch from Gustavo)
Tom Henderson <tomh@tomh.org>
parents:
1795
diff
changeset
|
148 |
|
6ab68edddf45
nicer logging of parameters (bug 79 patch from Gustavo)
Tom Henderson <tomh@tomh.org>
parents:
1795
diff
changeset
|
149 |
ParameterLogger& |
6ab68edddf45
nicer logging of parameters (bug 79 patch from Gustavo)
Tom Henderson <tomh@tomh.org>
parents:
1795
diff
changeset
|
150 |
operator << (ParameterName paramName) |
6ab68edddf45
nicer logging of parameters (bug 79 patch from Gustavo)
Tom Henderson <tomh@tomh.org>
parents:
1795
diff
changeset
|
151 |
{ |
6ab68edddf45
nicer logging of parameters (bug 79 patch from Gustavo)
Tom Henderson <tomh@tomh.org>
parents:
1795
diff
changeset
|
152 |
m_parameterName = paramName.name; |
6ab68edddf45
nicer logging of parameters (bug 79 patch from Gustavo)
Tom Henderson <tomh@tomh.org>
parents:
1795
diff
changeset
|
153 |
return *this; |
6ab68edddf45
nicer logging of parameters (bug 79 patch from Gustavo)
Tom Henderson <tomh@tomh.org>
parents:
1795
diff
changeset
|
154 |
} |
6ab68edddf45
nicer logging of parameters (bug 79 patch from Gustavo)
Tom Henderson <tomh@tomh.org>
parents:
1795
diff
changeset
|
155 |
|
6ab68edddf45
nicer logging of parameters (bug 79 patch from Gustavo)
Tom Henderson <tomh@tomh.org>
parents:
1795
diff
changeset
|
156 |
ParameterLogger& |
6ab68edddf45
nicer logging of parameters (bug 79 patch from Gustavo)
Tom Henderson <tomh@tomh.org>
parents:
1795
diff
changeset
|
157 |
operator << (EndParameterListStruct dummy) |
6ab68edddf45
nicer logging of parameters (bug 79 patch from Gustavo)
Tom Henderson <tomh@tomh.org>
parents:
1795
diff
changeset
|
158 |
{ |
6ab68edddf45
nicer logging of parameters (bug 79 patch from Gustavo)
Tom Henderson <tomh@tomh.org>
parents:
1795
diff
changeset
|
159 |
std::clog << ")" << std::endl; |
6ab68edddf45
nicer logging of parameters (bug 79 patch from Gustavo)
Tom Henderson <tomh@tomh.org>
parents:
1795
diff
changeset
|
160 |
m_itemNumber = 0; |
6ab68edddf45
nicer logging of parameters (bug 79 patch from Gustavo)
Tom Henderson <tomh@tomh.org>
parents:
1795
diff
changeset
|
161 |
return *this; |
6ab68edddf45
nicer logging of parameters (bug 79 patch from Gustavo)
Tom Henderson <tomh@tomh.org>
parents:
1795
diff
changeset
|
162 |
} |
6ab68edddf45
nicer logging of parameters (bug 79 patch from Gustavo)
Tom Henderson <tomh@tomh.org>
parents:
1795
diff
changeset
|
163 |
}; |
6ab68edddf45
nicer logging of parameters (bug 79 patch from Gustavo)
Tom Henderson <tomh@tomh.org>
parents:
1795
diff
changeset
|
164 |
|
6ab68edddf45
nicer logging of parameters (bug 79 patch from Gustavo)
Tom Henderson <tomh@tomh.org>
parents:
1795
diff
changeset
|
165 |
extern ParameterLogger g_parameterLogger; |
6ab68edddf45
nicer logging of parameters (bug 79 patch from Gustavo)
Tom Henderson <tomh@tomh.org>
parents:
1795
diff
changeset
|
166 |
|
6ab68edddf45
nicer logging of parameters (bug 79 patch from Gustavo)
Tom Henderson <tomh@tomh.org>
parents:
1795
diff
changeset
|
167 |
} |
6ab68edddf45
nicer logging of parameters (bug 79 patch from Gustavo)
Tom Henderson <tomh@tomh.org>
parents:
1795
diff
changeset
|
168 |
|
6ab68edddf45
nicer logging of parameters (bug 79 patch from Gustavo)
Tom Henderson <tomh@tomh.org>
parents:
1795
diff
changeset
|
169 |
|
6ab68edddf45
nicer logging of parameters (bug 79 patch from Gustavo)
Tom Henderson <tomh@tomh.org>
parents:
1795
diff
changeset
|
170 |
|
1795
820cc1254290
get rid of doxygen warnings
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1783
diff
changeset
|
171 |
/** |
820cc1254290
get rid of doxygen warnings
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1783
diff
changeset
|
172 |
* \param level the log level |
820cc1254290
get rid of doxygen warnings
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1783
diff
changeset
|
173 |
* \param msg the message to log |
820cc1254290
get rid of doxygen warnings
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1783
diff
changeset
|
174 |
* |
820cc1254290
get rid of doxygen warnings
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1783
diff
changeset
|
175 |
* This macro allows you to log an arbitrary message at a specific |
820cc1254290
get rid of doxygen warnings
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1783
diff
changeset
|
176 |
* log level. The log message is expected to be a C++ ostream |
820cc1254290
get rid of doxygen warnings
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1783
diff
changeset
|
177 |
* message such as "my string" << aNumber << "my oth stream". |
820cc1254290
get rid of doxygen warnings
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1783
diff
changeset
|
178 |
* |
820cc1254290
get rid of doxygen warnings
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1783
diff
changeset
|
179 |
* Typical usage looks like: |
820cc1254290
get rid of doxygen warnings
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1783
diff
changeset
|
180 |
* \code |
820cc1254290
get rid of doxygen warnings
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1783
diff
changeset
|
181 |
* NS_LOG (LOG_DEBUG, "a number="<<aNumber<<", anotherNumber="<<anotherNumber); |
820cc1254290
get rid of doxygen warnings
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1783
diff
changeset
|
182 |
* \endcode |
820cc1254290
get rid of doxygen warnings
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1783
diff
changeset
|
183 |
*/ |
1506
3c8b23550e6a
disable log unless debug build
Craig Dowell <craigdo@ee.washington.edu>
parents:
1504
diff
changeset
|
184 |
#define NS_LOG(level, msg) \ |
3c8b23550e6a
disable log unless debug build
Craig Dowell <craigdo@ee.washington.edu>
parents:
1504
diff
changeset
|
185 |
do \ |
3c8b23550e6a
disable log unless debug build
Craig Dowell <craigdo@ee.washington.edu>
parents:
1504
diff
changeset
|
186 |
{ \ |
3c8b23550e6a
disable log unless debug build
Craig Dowell <craigdo@ee.washington.edu>
parents:
1504
diff
changeset
|
187 |
if (g_log.IsEnabled (level)) \ |
3c8b23550e6a
disable log unless debug build
Craig Dowell <craigdo@ee.washington.edu>
parents:
1504
diff
changeset
|
188 |
{ \ |
1772
dd278e20e52e
log verbosity changes
Craig Dowell <craigdo@ee.washington.edu>
parents:
1507
diff
changeset
|
189 |
if (g_log.IsEnabled (ns3::LOG_PREFIX_ALL)) \ |
dd278e20e52e
log verbosity changes
Craig Dowell <craigdo@ee.washington.edu>
parents:
1507
diff
changeset
|
190 |
{ \ |
dd278e20e52e
log verbosity changes
Craig Dowell <craigdo@ee.washington.edu>
parents:
1507
diff
changeset
|
191 |
std::clog << g_log.Name () << ":" << \ |
dd278e20e52e
log verbosity changes
Craig Dowell <craigdo@ee.washington.edu>
parents:
1507
diff
changeset
|
192 |
__FUNCTION__ << "(): "; \ |
dd278e20e52e
log verbosity changes
Craig Dowell <craigdo@ee.washington.edu>
parents:
1507
diff
changeset
|
193 |
} \ |
dd278e20e52e
log verbosity changes
Craig Dowell <craigdo@ee.washington.edu>
parents:
1507
diff
changeset
|
194 |
std::clog << msg << std::endl; \ |
1506
3c8b23550e6a
disable log unless debug build
Craig Dowell <craigdo@ee.washington.edu>
parents:
1504
diff
changeset
|
195 |
} \ |
3c8b23550e6a
disable log unless debug build
Craig Dowell <craigdo@ee.washington.edu>
parents:
1504
diff
changeset
|
196 |
} \ |
1498
520bc8457799
log rides along for free
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
197 |
while (false) |
520bc8457799
log rides along for free
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
198 |
|
1772
dd278e20e52e
log verbosity changes
Craig Dowell <craigdo@ee.washington.edu>
parents:
1507
diff
changeset
|
199 |
#define NS_LOG_F(level) \ |
dd278e20e52e
log verbosity changes
Craig Dowell <craigdo@ee.washington.edu>
parents:
1507
diff
changeset
|
200 |
do \ |
dd278e20e52e
log verbosity changes
Craig Dowell <craigdo@ee.washington.edu>
parents:
1507
diff
changeset
|
201 |
{ \ |
dd278e20e52e
log verbosity changes
Craig Dowell <craigdo@ee.washington.edu>
parents:
1507
diff
changeset
|
202 |
if (g_log.IsEnabled (level)) \ |
dd278e20e52e
log verbosity changes
Craig Dowell <craigdo@ee.washington.edu>
parents:
1507
diff
changeset
|
203 |
{ \ |
dd278e20e52e
log verbosity changes
Craig Dowell <craigdo@ee.washington.edu>
parents:
1507
diff
changeset
|
204 |
std::clog << g_log.Name () << ":" << __FUNCTION__ << \ |
1783
36472385a1cc
NS_LOG parsing changes to address bug 91
Craig Dowell <craigdo@ee.washington.edu>
parents:
1775
diff
changeset
|
205 |
"()" << std::endl; \ |
1772
dd278e20e52e
log verbosity changes
Craig Dowell <craigdo@ee.washington.edu>
parents:
1507
diff
changeset
|
206 |
} \ |
dd278e20e52e
log verbosity changes
Craig Dowell <craigdo@ee.washington.edu>
parents:
1507
diff
changeset
|
207 |
} \ |
1504
36ecc970ba96
checkpoint debug to log
Craig Dowell <craigdo@ee.washington.edu>
parents:
1503
diff
changeset
|
208 |
while (false) |
36ecc970ba96
checkpoint debug to log
Craig Dowell <craigdo@ee.washington.edu>
parents:
1503
diff
changeset
|
209 |
|
1503
53dd8f414ba6
sorting out logging
Craig Dowell <craigdo@ee.washington.edu>
parents:
1498
diff
changeset
|
210 |
#define NS_LOG_ERROR(msg) \ |
1507
11a370eecc52
allow discrete levels
Craig Dowell <craigdo@ee.washington.edu>
parents:
1506
diff
changeset
|
211 |
NS_LOG(ns3::LOG_ERROR, msg) |
1498
520bc8457799
log rides along for free
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
212 |
|
520bc8457799
log rides along for free
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
213 |
#define NS_LOG_WARN(msg) \ |
1507
11a370eecc52
allow discrete levels
Craig Dowell <craigdo@ee.washington.edu>
parents:
1506
diff
changeset
|
214 |
NS_LOG(ns3::LOG_WARN, msg) |
1503
53dd8f414ba6
sorting out logging
Craig Dowell <craigdo@ee.washington.edu>
parents:
1498
diff
changeset
|
215 |
|
53dd8f414ba6
sorting out logging
Craig Dowell <craigdo@ee.washington.edu>
parents:
1498
diff
changeset
|
216 |
#define NS_LOG_DEBUG(msg) \ |
1507
11a370eecc52
allow discrete levels
Craig Dowell <craigdo@ee.washington.edu>
parents:
1506
diff
changeset
|
217 |
NS_LOG(ns3::LOG_DEBUG, msg) |
1498
520bc8457799
log rides along for free
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
218 |
|
1503
53dd8f414ba6
sorting out logging
Craig Dowell <craigdo@ee.washington.edu>
parents:
1498
diff
changeset
|
219 |
#define NS_LOG_INFO(msg) \ |
1507
11a370eecc52
allow discrete levels
Craig Dowell <craigdo@ee.washington.edu>
parents:
1506
diff
changeset
|
220 |
NS_LOG(ns3::LOG_INFO, msg) |
1503
53dd8f414ba6
sorting out logging
Craig Dowell <craigdo@ee.washington.edu>
parents:
1498
diff
changeset
|
221 |
|
1504
36ecc970ba96
checkpoint debug to log
Craig Dowell <craigdo@ee.washington.edu>
parents:
1503
diff
changeset
|
222 |
#define NS_LOG_FUNCTION \ |
1507
11a370eecc52
allow discrete levels
Craig Dowell <craigdo@ee.washington.edu>
parents:
1506
diff
changeset
|
223 |
NS_LOG_F(ns3::LOG_FUNCTION) |
1498
520bc8457799
log rides along for free
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
224 |
|
1828
6ab68edddf45
nicer logging of parameters (bug 79 patch from Gustavo)
Tom Henderson <tomh@tomh.org>
parents:
1795
diff
changeset
|
225 |
|
6ab68edddf45
nicer logging of parameters (bug 79 patch from Gustavo)
Tom Henderson <tomh@tomh.org>
parents:
1795
diff
changeset
|
226 |
|
6ab68edddf45
nicer logging of parameters (bug 79 patch from Gustavo)
Tom Henderson <tomh@tomh.org>
parents:
1795
diff
changeset
|
227 |
#define NS_LOG_PARAMS(parameters) \ |
6ab68edddf45
nicer logging of parameters (bug 79 patch from Gustavo)
Tom Henderson <tomh@tomh.org>
parents:
1795
diff
changeset
|
228 |
do \ |
6ab68edddf45
nicer logging of parameters (bug 79 patch from Gustavo)
Tom Henderson <tomh@tomh.org>
parents:
1795
diff
changeset
|
229 |
{ \ |
6ab68edddf45
nicer logging of parameters (bug 79 patch from Gustavo)
Tom Henderson <tomh@tomh.org>
parents:
1795
diff
changeset
|
230 |
if (g_log.IsEnabled (ns3::LOG_PARAM)) \ |
6ab68edddf45
nicer logging of parameters (bug 79 patch from Gustavo)
Tom Henderson <tomh@tomh.org>
parents:
1795
diff
changeset
|
231 |
{ \ |
6ab68edddf45
nicer logging of parameters (bug 79 patch from Gustavo)
Tom Henderson <tomh@tomh.org>
parents:
1795
diff
changeset
|
232 |
g_parameterLogger << __PRETTY_FUNCTION__ \ |
6ab68edddf45
nicer logging of parameters (bug 79 patch from Gustavo)
Tom Henderson <tomh@tomh.org>
parents:
1795
diff
changeset
|
233 |
<< parameters \ |
6ab68edddf45
nicer logging of parameters (bug 79 patch from Gustavo)
Tom Henderson <tomh@tomh.org>
parents:
1795
diff
changeset
|
234 |
<< EndParameterList; \ |
6ab68edddf45
nicer logging of parameters (bug 79 patch from Gustavo)
Tom Henderson <tomh@tomh.org>
parents:
1795
diff
changeset
|
235 |
} \ |
6ab68edddf45
nicer logging of parameters (bug 79 patch from Gustavo)
Tom Henderson <tomh@tomh.org>
parents:
1795
diff
changeset
|
236 |
} \ |
6ab68edddf45
nicer logging of parameters (bug 79 patch from Gustavo)
Tom Henderson <tomh@tomh.org>
parents:
1795
diff
changeset
|
237 |
while (false) |
6ab68edddf45
nicer logging of parameters (bug 79 patch from Gustavo)
Tom Henderson <tomh@tomh.org>
parents:
1795
diff
changeset
|
238 |
|
6ab68edddf45
nicer logging of parameters (bug 79 patch from Gustavo)
Tom Henderson <tomh@tomh.org>
parents:
1795
diff
changeset
|
239 |
|
6ab68edddf45
nicer logging of parameters (bug 79 patch from Gustavo)
Tom Henderson <tomh@tomh.org>
parents:
1795
diff
changeset
|
240 |
#define NS_LOG_PARAMS_BEGIN() \ |
6ab68edddf45
nicer logging of parameters (bug 79 patch from Gustavo)
Tom Henderson <tomh@tomh.org>
parents:
1795
diff
changeset
|
241 |
if (g_log.IsEnabled (ns3::LOG_PARAM)) \ |
6ab68edddf45
nicer logging of parameters (bug 79 patch from Gustavo)
Tom Henderson <tomh@tomh.org>
parents:
1795
diff
changeset
|
242 |
{ \ |
6ab68edddf45
nicer logging of parameters (bug 79 patch from Gustavo)
Tom Henderson <tomh@tomh.org>
parents:
1795
diff
changeset
|
243 |
g_parameterLogger << __PRETTY_FUNCTION__; |
6ab68edddf45
nicer logging of parameters (bug 79 patch from Gustavo)
Tom Henderson <tomh@tomh.org>
parents:
1795
diff
changeset
|
244 |
|
6ab68edddf45
nicer logging of parameters (bug 79 patch from Gustavo)
Tom Henderson <tomh@tomh.org>
parents:
1795
diff
changeset
|
245 |
#define NS_LOG_PARAM(param) \ |
6ab68edddf45
nicer logging of parameters (bug 79 patch from Gustavo)
Tom Henderson <tomh@tomh.org>
parents:
1795
diff
changeset
|
246 |
g_parameterLogger << ParameterName (#param) << param; |
6ab68edddf45
nicer logging of parameters (bug 79 patch from Gustavo)
Tom Henderson <tomh@tomh.org>
parents:
1795
diff
changeset
|
247 |
|
6ab68edddf45
nicer logging of parameters (bug 79 patch from Gustavo)
Tom Henderson <tomh@tomh.org>
parents:
1795
diff
changeset
|
248 |
#define NS_LOG_PARAMS_END() \ |
6ab68edddf45
nicer logging of parameters (bug 79 patch from Gustavo)
Tom Henderson <tomh@tomh.org>
parents:
1795
diff
changeset
|
249 |
g_parameterLogger << EndParameterList; \ |
6ab68edddf45
nicer logging of parameters (bug 79 patch from Gustavo)
Tom Henderson <tomh@tomh.org>
parents:
1795
diff
changeset
|
250 |
} |
6ab68edddf45
nicer logging of parameters (bug 79 patch from Gustavo)
Tom Henderson <tomh@tomh.org>
parents:
1795
diff
changeset
|
251 |
|
1503
53dd8f414ba6
sorting out logging
Craig Dowell <craigdo@ee.washington.edu>
parents:
1498
diff
changeset
|
252 |
|
53dd8f414ba6
sorting out logging
Craig Dowell <craigdo@ee.washington.edu>
parents:
1498
diff
changeset
|
253 |
#define NS_LOG_LOGIC(msg) \ |
1507
11a370eecc52
allow discrete levels
Craig Dowell <craigdo@ee.washington.edu>
parents:
1506
diff
changeset
|
254 |
NS_LOG(ns3::LOG_LOGIC, msg) |
1503
53dd8f414ba6
sorting out logging
Craig Dowell <craigdo@ee.washington.edu>
parents:
1498
diff
changeset
|
255 |
|
53dd8f414ba6
sorting out logging
Craig Dowell <craigdo@ee.washington.edu>
parents:
1498
diff
changeset
|
256 |
#define NS_LOG_UNCOND(msg) \ |
53dd8f414ba6
sorting out logging
Craig Dowell <craigdo@ee.washington.edu>
parents:
1498
diff
changeset
|
257 |
do \ |
53dd8f414ba6
sorting out logging
Craig Dowell <craigdo@ee.washington.edu>
parents:
1498
diff
changeset
|
258 |
{ \ |
53dd8f414ba6
sorting out logging
Craig Dowell <craigdo@ee.washington.edu>
parents:
1498
diff
changeset
|
259 |
std::clog << msg << std::endl; \ |
53dd8f414ba6
sorting out logging
Craig Dowell <craigdo@ee.washington.edu>
parents:
1498
diff
changeset
|
260 |
} \ |
1498
520bc8457799
log rides along for free
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
261 |
while (false) |
520bc8457799
log rides along for free
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
262 |
|
1506
3c8b23550e6a
disable log unless debug build
Craig Dowell <craigdo@ee.washington.edu>
parents:
1504
diff
changeset
|
263 |
#else |
3c8b23550e6a
disable log unless debug build
Craig Dowell <craigdo@ee.washington.edu>
parents:
1504
diff
changeset
|
264 |
|
3c8b23550e6a
disable log unless debug build
Craig Dowell <craigdo@ee.washington.edu>
parents:
1504
diff
changeset
|
265 |
#define NS_LOG(level, msg) |
3c8b23550e6a
disable log unless debug build
Craig Dowell <craigdo@ee.washington.edu>
parents:
1504
diff
changeset
|
266 |
#define NS_LOG_F(level) |
3c8b23550e6a
disable log unless debug build
Craig Dowell <craigdo@ee.washington.edu>
parents:
1504
diff
changeset
|
267 |
#define NS_LOG_ERROR(msg) |
3c8b23550e6a
disable log unless debug build
Craig Dowell <craigdo@ee.washington.edu>
parents:
1504
diff
changeset
|
268 |
#define NS_LOG_WARN(msg) |
3c8b23550e6a
disable log unless debug build
Craig Dowell <craigdo@ee.washington.edu>
parents:
1504
diff
changeset
|
269 |
#define NS_LOG_DEBUG(msg) |
3c8b23550e6a
disable log unless debug build
Craig Dowell <craigdo@ee.washington.edu>
parents:
1504
diff
changeset
|
270 |
#define NS_LOG_INFO(msg) |
3c8b23550e6a
disable log unless debug build
Craig Dowell <craigdo@ee.washington.edu>
parents:
1504
diff
changeset
|
271 |
#define NS_LOG_FUNCTION |
1830
8fead8808f3f
Add some missing NS_LOG_PARAM* definitions in optimized build
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
1828
diff
changeset
|
272 |
#define NS_LOG_PARAMS(parameters) |
8fead8808f3f
Add some missing NS_LOG_PARAM* definitions in optimized build
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
1828
diff
changeset
|
273 |
#define NS_LOG_PARAMS_BEGIN() |
8fead8808f3f
Add some missing NS_LOG_PARAM* definitions in optimized build
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
1828
diff
changeset
|
274 |
#define NS_LOG_PARAM(param) |
8fead8808f3f
Add some missing NS_LOG_PARAM* definitions in optimized build
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
1828
diff
changeset
|
275 |
#define NS_LOG_PARAMS_END() |
1506
3c8b23550e6a
disable log unless debug build
Craig Dowell <craigdo@ee.washington.edu>
parents:
1504
diff
changeset
|
276 |
#define NS_LOG_LOGIC(msg) |
3c8b23550e6a
disable log unless debug build
Craig Dowell <craigdo@ee.washington.edu>
parents:
1504
diff
changeset
|
277 |
#define NS_LOG_UNCOND(msg) |
3c8b23550e6a
disable log unless debug build
Craig Dowell <craigdo@ee.washington.edu>
parents:
1504
diff
changeset
|
278 |
|
3c8b23550e6a
disable log unless debug build
Craig Dowell <craigdo@ee.washington.edu>
parents:
1504
diff
changeset
|
279 |
#endif |
3c8b23550e6a
disable log unless debug build
Craig Dowell <craigdo@ee.washington.edu>
parents:
1504
diff
changeset
|
280 |
|
1498
520bc8457799
log rides along for free
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
281 |
namespace ns3 { |
520bc8457799
log rides along for free
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
282 |
|
1506
3c8b23550e6a
disable log unless debug build
Craig Dowell <craigdo@ee.washington.edu>
parents:
1504
diff
changeset
|
283 |
#ifdef NS3_LOG_ENABLE |
3c8b23550e6a
disable log unless debug build
Craig Dowell <craigdo@ee.washington.edu>
parents:
1504
diff
changeset
|
284 |
|
1498
520bc8457799
log rides along for free
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
285 |
enum LogLevel { |
1772
dd278e20e52e
log verbosity changes
Craig Dowell <craigdo@ee.washington.edu>
parents:
1507
diff
changeset
|
286 |
LOG_NONE = 0x00000000, // no logging |
1507
11a370eecc52
allow discrete levels
Craig Dowell <craigdo@ee.washington.edu>
parents:
1506
diff
changeset
|
287 |
|
1772
dd278e20e52e
log verbosity changes
Craig Dowell <craigdo@ee.washington.edu>
parents:
1507
diff
changeset
|
288 |
LOG_ERROR = 0x00000001, // serious error messages only |
dd278e20e52e
log verbosity changes
Craig Dowell <craigdo@ee.washington.edu>
parents:
1507
diff
changeset
|
289 |
LOG_LEVEL_ERROR = 0x00000001, |
1507
11a370eecc52
allow discrete levels
Craig Dowell <craigdo@ee.washington.edu>
parents:
1506
diff
changeset
|
290 |
|
1772
dd278e20e52e
log verbosity changes
Craig Dowell <craigdo@ee.washington.edu>
parents:
1507
diff
changeset
|
291 |
LOG_WARN = 0x00000002, // warning messages |
dd278e20e52e
log verbosity changes
Craig Dowell <craigdo@ee.washington.edu>
parents:
1507
diff
changeset
|
292 |
LOG_LEVEL_WARN = 0x00000003, |
1507
11a370eecc52
allow discrete levels
Craig Dowell <craigdo@ee.washington.edu>
parents:
1506
diff
changeset
|
293 |
|
1772
dd278e20e52e
log verbosity changes
Craig Dowell <craigdo@ee.washington.edu>
parents:
1507
diff
changeset
|
294 |
LOG_DEBUG = 0x00000004, // rare ad-hoc debug messages |
dd278e20e52e
log verbosity changes
Craig Dowell <craigdo@ee.washington.edu>
parents:
1507
diff
changeset
|
295 |
LOG_LEVEL_DEBUG = 0x00000007, |
dd278e20e52e
log verbosity changes
Craig Dowell <craigdo@ee.washington.edu>
parents:
1507
diff
changeset
|
296 |
|
dd278e20e52e
log verbosity changes
Craig Dowell <craigdo@ee.washington.edu>
parents:
1507
diff
changeset
|
297 |
LOG_INFO = 0x00000008, // informational messages (e.g., banners) |
dd278e20e52e
log verbosity changes
Craig Dowell <craigdo@ee.washington.edu>
parents:
1507
diff
changeset
|
298 |
LOG_LEVEL_INFO = 0x0000000f, |
1507
11a370eecc52
allow discrete levels
Craig Dowell <craigdo@ee.washington.edu>
parents:
1506
diff
changeset
|
299 |
|
1772
dd278e20e52e
log verbosity changes
Craig Dowell <craigdo@ee.washington.edu>
parents:
1507
diff
changeset
|
300 |
LOG_FUNCTION = 0x00000010, // function tracing |
dd278e20e52e
log verbosity changes
Craig Dowell <craigdo@ee.washington.edu>
parents:
1507
diff
changeset
|
301 |
LOG_LEVEL_FUNCTION = 0x0000001f, |
1507
11a370eecc52
allow discrete levels
Craig Dowell <craigdo@ee.washington.edu>
parents:
1506
diff
changeset
|
302 |
|
1772
dd278e20e52e
log verbosity changes
Craig Dowell <craigdo@ee.washington.edu>
parents:
1507
diff
changeset
|
303 |
LOG_PARAM = 0x00000020, // parameters to functions |
dd278e20e52e
log verbosity changes
Craig Dowell <craigdo@ee.washington.edu>
parents:
1507
diff
changeset
|
304 |
LOG_LEVEL_PARAM = 0x0000003f, |
1507
11a370eecc52
allow discrete levels
Craig Dowell <craigdo@ee.washington.edu>
parents:
1506
diff
changeset
|
305 |
|
1772
dd278e20e52e
log verbosity changes
Craig Dowell <craigdo@ee.washington.edu>
parents:
1507
diff
changeset
|
306 |
LOG_LOGIC = 0x00000040, // control flow tracing within functions |
dd278e20e52e
log verbosity changes
Craig Dowell <craigdo@ee.washington.edu>
parents:
1507
diff
changeset
|
307 |
LOG_LEVEL_LOGIC = 0x0000007f, |
1507
11a370eecc52
allow discrete levels
Craig Dowell <craigdo@ee.washington.edu>
parents:
1506
diff
changeset
|
308 |
|
1772
dd278e20e52e
log verbosity changes
Craig Dowell <craigdo@ee.washington.edu>
parents:
1507
diff
changeset
|
309 |
LOG_ALL = 0x7fffffff, // print everything |
dd278e20e52e
log verbosity changes
Craig Dowell <craigdo@ee.washington.edu>
parents:
1507
diff
changeset
|
310 |
LOG_LEVEL_ALL = LOG_ALL, |
dd278e20e52e
log verbosity changes
Craig Dowell <craigdo@ee.washington.edu>
parents:
1507
diff
changeset
|
311 |
|
1775
5abf6f0d1eca
deal with static constructor problem
Craig Dowell <craigdo@ee.washington.edu>
parents:
1772
diff
changeset
|
312 |
LOG_PREFIX_ALL = 0x80000000 // prefix all trace prints with function |
1498
520bc8457799
log rides along for free
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
313 |
}; |
520bc8457799
log rides along for free
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
314 |
|
1506
3c8b23550e6a
disable log unless debug build
Craig Dowell <craigdo@ee.washington.edu>
parents:
1504
diff
changeset
|
315 |
#endif |
3c8b23550e6a
disable log unless debug build
Craig Dowell <craigdo@ee.washington.edu>
parents:
1504
diff
changeset
|
316 |
|
1772
dd278e20e52e
log verbosity changes
Craig Dowell <craigdo@ee.washington.edu>
parents:
1507
diff
changeset
|
317 |
#ifdef NS3_LOG_ENABLE |
1498
520bc8457799
log rides along for free
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
318 |
/** |
520bc8457799
log rides along for free
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
319 |
* \param name a log component name |
1772
dd278e20e52e
log verbosity changes
Craig Dowell <craigdo@ee.washington.edu>
parents:
1507
diff
changeset
|
320 |
* \param level a logging level |
1498
520bc8457799
log rides along for free
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
321 |
* \ingroup logging |
520bc8457799
log rides along for free
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
322 |
* |
520bc8457799
log rides along for free
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
323 |
* Enable the logging output associated with that log component. |
520bc8457799
log rides along for free
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
324 |
* The logging output can be later disabled with a call |
520bc8457799
log rides along for free
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
325 |
* to ns3::LogComponentDisable. |
520bc8457799
log rides along for free
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
326 |
*/ |
1772
dd278e20e52e
log verbosity changes
Craig Dowell <craigdo@ee.washington.edu>
parents:
1507
diff
changeset
|
327 |
void LogComponentEnable (char const *name, enum LogLevel level); |
1775
5abf6f0d1eca
deal with static constructor problem
Craig Dowell <craigdo@ee.washington.edu>
parents:
1772
diff
changeset
|
328 |
|
1772
dd278e20e52e
log verbosity changes
Craig Dowell <craigdo@ee.washington.edu>
parents:
1507
diff
changeset
|
329 |
/** |
dd278e20e52e
log verbosity changes
Craig Dowell <craigdo@ee.washington.edu>
parents:
1507
diff
changeset
|
330 |
* \param level a logging level |
dd278e20e52e
log verbosity changes
Craig Dowell <craigdo@ee.washington.edu>
parents:
1507
diff
changeset
|
331 |
* \ingroup logging |
dd278e20e52e
log verbosity changes
Craig Dowell <craigdo@ee.washington.edu>
parents:
1507
diff
changeset
|
332 |
* |
dd278e20e52e
log verbosity changes
Craig Dowell <craigdo@ee.washington.edu>
parents:
1507
diff
changeset
|
333 |
* Enable the logging output for all registered log components. |
dd278e20e52e
log verbosity changes
Craig Dowell <craigdo@ee.washington.edu>
parents:
1507
diff
changeset
|
334 |
*/ |
dd278e20e52e
log verbosity changes
Craig Dowell <craigdo@ee.washington.edu>
parents:
1507
diff
changeset
|
335 |
void LogComponentEnableAll (enum LogLevel level); |
1506
3c8b23550e6a
disable log unless debug build
Craig Dowell <craigdo@ee.washington.edu>
parents:
1504
diff
changeset
|
336 |
#else |
3c8b23550e6a
disable log unless debug build
Craig Dowell <craigdo@ee.washington.edu>
parents:
1504
diff
changeset
|
337 |
#define LogComponentEnable(a,b) |
1772
dd278e20e52e
log verbosity changes
Craig Dowell <craigdo@ee.washington.edu>
parents:
1507
diff
changeset
|
338 |
#define LogComponentEnableAll(a) |
1506
3c8b23550e6a
disable log unless debug build
Craig Dowell <craigdo@ee.washington.edu>
parents:
1504
diff
changeset
|
339 |
#endif |
1498
520bc8457799
log rides along for free
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
340 |
|
1772
dd278e20e52e
log verbosity changes
Craig Dowell <craigdo@ee.washington.edu>
parents:
1507
diff
changeset
|
341 |
#ifdef NS3_LOG_ENABLE |
1498
520bc8457799
log rides along for free
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
342 |
/** |
520bc8457799
log rides along for free
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
343 |
* \param name a log component name |
1772
dd278e20e52e
log verbosity changes
Craig Dowell <craigdo@ee.washington.edu>
parents:
1507
diff
changeset
|
344 |
* \param level a logging level |
1498
520bc8457799
log rides along for free
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
345 |
* \ingroup logging |
520bc8457799
log rides along for free
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
346 |
* |
520bc8457799
log rides along for free
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
347 |
* Disable the logging output associated with that log component. |
520bc8457799
log rides along for free
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
348 |
* The logging output can be later re-enabled with a call |
520bc8457799
log rides along for free
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
349 |
* to ns3::LogComponentEnable. |
520bc8457799
log rides along for free
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
350 |
*/ |
520bc8457799
log rides along for free
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
351 |
void LogComponentDisable (char const *name, enum LogLevel level); |
1772
dd278e20e52e
log verbosity changes
Craig Dowell <craigdo@ee.washington.edu>
parents:
1507
diff
changeset
|
352 |
|
dd278e20e52e
log verbosity changes
Craig Dowell <craigdo@ee.washington.edu>
parents:
1507
diff
changeset
|
353 |
/** |
dd278e20e52e
log verbosity changes
Craig Dowell <craigdo@ee.washington.edu>
parents:
1507
diff
changeset
|
354 |
* \param level a logging level |
dd278e20e52e
log verbosity changes
Craig Dowell <craigdo@ee.washington.edu>
parents:
1507
diff
changeset
|
355 |
* \ingroup logging |
dd278e20e52e
log verbosity changes
Craig Dowell <craigdo@ee.washington.edu>
parents:
1507
diff
changeset
|
356 |
* |
1795
820cc1254290
get rid of doxygen warnings
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1783
diff
changeset
|
357 |
* Disable all logging for all components. |
1772
dd278e20e52e
log verbosity changes
Craig Dowell <craigdo@ee.washington.edu>
parents:
1507
diff
changeset
|
358 |
*/ |
dd278e20e52e
log verbosity changes
Craig Dowell <craigdo@ee.washington.edu>
parents:
1507
diff
changeset
|
359 |
void LogComponentDisableAll (enum LogLevel level); |
dd278e20e52e
log verbosity changes
Craig Dowell <craigdo@ee.washington.edu>
parents:
1507
diff
changeset
|
360 |
|
1506
3c8b23550e6a
disable log unless debug build
Craig Dowell <craigdo@ee.washington.edu>
parents:
1504
diff
changeset
|
361 |
#else |
3c8b23550e6a
disable log unless debug build
Craig Dowell <craigdo@ee.washington.edu>
parents:
1504
diff
changeset
|
362 |
#define LogComponentDisable(a,b) |
1772
dd278e20e52e
log verbosity changes
Craig Dowell <craigdo@ee.washington.edu>
parents:
1507
diff
changeset
|
363 |
#define LogComponentDisableAll(a) |
1506
3c8b23550e6a
disable log unless debug build
Craig Dowell <craigdo@ee.washington.edu>
parents:
1504
diff
changeset
|
364 |
#endif |
1498
520bc8457799
log rides along for free
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
365 |
|
520bc8457799
log rides along for free
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
366 |
/** |
520bc8457799
log rides along for free
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
367 |
* \ingroup logging |
520bc8457799
log rides along for free
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
368 |
* |
520bc8457799
log rides along for free
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
369 |
* Print the list of logging messages available. |
520bc8457799
log rides along for free
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
370 |
*/ |
1506
3c8b23550e6a
disable log unless debug build
Craig Dowell <craigdo@ee.washington.edu>
parents:
1504
diff
changeset
|
371 |
#ifdef NS3_LOG_ENABLE |
1498
520bc8457799
log rides along for free
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
372 |
void LogComponentPrintList (void); |
1506
3c8b23550e6a
disable log unless debug build
Craig Dowell <craigdo@ee.washington.edu>
parents:
1504
diff
changeset
|
373 |
#else |
3c8b23550e6a
disable log unless debug build
Craig Dowell <craigdo@ee.washington.edu>
parents:
1504
diff
changeset
|
374 |
#define LogComponentPrintList() |
3c8b23550e6a
disable log unless debug build
Craig Dowell <craigdo@ee.washington.edu>
parents:
1504
diff
changeset
|
375 |
#endif |
3c8b23550e6a
disable log unless debug build
Craig Dowell <craigdo@ee.washington.edu>
parents:
1504
diff
changeset
|
376 |
|
3c8b23550e6a
disable log unless debug build
Craig Dowell <craigdo@ee.washington.edu>
parents:
1504
diff
changeset
|
377 |
#ifdef NS3_LOG_ENABLE |
1498
520bc8457799
log rides along for free
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
378 |
|
520bc8457799
log rides along for free
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
379 |
class LogComponent { |
520bc8457799
log rides along for free
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
380 |
public: |
520bc8457799
log rides along for free
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
381 |
LogComponent (char const *name); |
1783
36472385a1cc
NS_LOG parsing changes to address bug 91
Craig Dowell <craigdo@ee.washington.edu>
parents:
1775
diff
changeset
|
382 |
void EnvVarCheck (char const *name); |
1498
520bc8457799
log rides along for free
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
383 |
bool IsEnabled (enum LogLevel level) const; |
520bc8457799
log rides along for free
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
384 |
bool IsNoneEnabled (void) const; |
520bc8457799
log rides along for free
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
385 |
void Enable (enum LogLevel level); |
520bc8457799
log rides along for free
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
386 |
void Disable (enum LogLevel level); |
1772
dd278e20e52e
log verbosity changes
Craig Dowell <craigdo@ee.washington.edu>
parents:
1507
diff
changeset
|
387 |
bool Decorate (void) const; |
dd278e20e52e
log verbosity changes
Craig Dowell <craigdo@ee.washington.edu>
parents:
1507
diff
changeset
|
388 |
char const *Name (void) const; |
1498
520bc8457799
log rides along for free
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
389 |
private: |
1772
dd278e20e52e
log verbosity changes
Craig Dowell <craigdo@ee.washington.edu>
parents:
1507
diff
changeset
|
390 |
int32_t m_levels; |
dd278e20e52e
log verbosity changes
Craig Dowell <craigdo@ee.washington.edu>
parents:
1507
diff
changeset
|
391 |
char const *m_name; |
dd278e20e52e
log verbosity changes
Craig Dowell <craigdo@ee.washington.edu>
parents:
1507
diff
changeset
|
392 |
bool m_decorate; |
1498
520bc8457799
log rides along for free
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
393 |
}; |
520bc8457799
log rides along for free
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
394 |
|
1506
3c8b23550e6a
disable log unless debug build
Craig Dowell <craigdo@ee.washington.edu>
parents:
1504
diff
changeset
|
395 |
#endif |
3c8b23550e6a
disable log unless debug build
Craig Dowell <craigdo@ee.washington.edu>
parents:
1504
diff
changeset
|
396 |
|
1498
520bc8457799
log rides along for free
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
397 |
} // namespace ns3 |
520bc8457799
log rides along for free
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
398 |
|
1506
3c8b23550e6a
disable log unless debug build
Craig Dowell <craigdo@ee.washington.edu>
parents:
1504
diff
changeset
|
399 |
#endif // __LOG_H__ |