author | Craig Dowell <craigdo@ee.washington.edu> |
Thu, 13 Sep 2007 22:17:29 -0700 | |
changeset 1506 | 3c8b23550e6a |
parent 1504 | 36ecc970ba96 |
child 1507 | 11a370eecc52 |
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 |
/** |
520bc8457799
log rides along for free
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
28 |
* \defgroup logging Logging |
520bc8457799
log rides along for free
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
29 |
* \brief Logging functions and macros |
520bc8457799
log rides along for free
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
30 |
* |
520bc8457799
log rides along for free
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
31 |
* LOG functionality: macros which allow developers to |
520bc8457799
log rides along for free
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
32 |
* send information out on screen. All logging messages |
520bc8457799
log rides along for free
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
33 |
* are disabled by default. To enable selected logging |
520bc8457799
log rides along for free
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
34 |
* messages, use the ns3::LogComponentEnable |
520bc8457799
log rides along for free
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
35 |
* function. |
520bc8457799
log rides along for free
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
36 |
* |
520bc8457799
log rides along for free
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
37 |
* Alternatively, you can use the NS_LOG |
520bc8457799
log rides along for free
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
38 |
* environment variable to define a ';'-separated list of |
520bc8457799
log rides along for free
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
39 |
* logging components to enable. For example, NS_LOG=a;b;c;DAFD;GH |
520bc8457799
log rides along for free
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
40 |
* would enable the components 'a', 'b', 'c', 'DAFD', and, 'GH'. |
520bc8457799
log rides along for free
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
41 |
* |
520bc8457799
log rides along for free
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
42 |
* For each component, the "debug" log level is enabled by default |
520bc8457799
log rides along for free
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
43 |
* but more components can be enabled selectively with the following |
520bc8457799
log rides along for free
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
44 |
* syntax: NS_LOG='Component1=func|param|warn;Component2=error|debug' |
520bc8457799
log rides along for free
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
45 |
* This example would enable the 'func', 'param', and 'warn' log |
520bc8457799
log rides along for free
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
46 |
* levels for 'Component1' and the 'error' and 'debug' log levels |
520bc8457799
log rides along for free
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
47 |
* for 'Component2'. |
520bc8457799
log rides along for free
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
48 |
* |
520bc8457799
log rides along for free
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
49 |
* The list of available log components can be printed on stdout |
520bc8457799
log rides along for free
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
50 |
* with the NS_LOG=print-list syntax. |
520bc8457799
log rides along for free
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
51 |
*/ |
520bc8457799
log rides along for free
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
52 |
|
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 |
* \ingroup logging |
520bc8457799
log rides along for free
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
55 |
* \param name a string |
520bc8457799
log rides along for free
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
56 |
* |
520bc8457799
log rides along for free
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
57 |
* 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
|
58 |
* 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
|
59 |
* 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
|
60 |
* "log component" which can be later selectively enabled |
520bc8457799
log rides along for free
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
61 |
* or disabled with the ns3::LogComponentEnable and |
520bc8457799
log rides along for free
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
62 |
* ns3::LogComponentDisable functions or with the NS_LOG |
520bc8457799
log rides along for free
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
63 |
* environment variable. |
520bc8457799
log rides along for free
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
64 |
*/ |
1506
3c8b23550e6a
disable log unless debug build
Craig Dowell <craigdo@ee.washington.edu>
parents:
1504
diff
changeset
|
65 |
|
3c8b23550e6a
disable log unless debug build
Craig Dowell <craigdo@ee.washington.edu>
parents:
1504
diff
changeset
|
66 |
#ifdef NS3_LOG_ENABLE |
3c8b23550e6a
disable log unless debug build
Craig Dowell <craigdo@ee.washington.edu>
parents:
1504
diff
changeset
|
67 |
|
1498
520bc8457799
log rides along for free
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
68 |
#define NS_LOG_COMPONENT_DEFINE(name) \ |
520bc8457799
log rides along for free
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
69 |
static ns3::LogComponent g_log = ns3::LogComponent (name) |
520bc8457799
log rides along for free
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
70 |
|
1506
3c8b23550e6a
disable log unless debug build
Craig Dowell <craigdo@ee.washington.edu>
parents:
1504
diff
changeset
|
71 |
#else |
3c8b23550e6a
disable log unless debug build
Craig Dowell <craigdo@ee.washington.edu>
parents:
1504
diff
changeset
|
72 |
|
3c8b23550e6a
disable log unless debug build
Craig Dowell <craigdo@ee.washington.edu>
parents:
1504
diff
changeset
|
73 |
#define NS_LOG_COMPONENT_DEFINE(name) |
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 |
#endif |
3c8b23550e6a
disable log unless debug build
Craig Dowell <craigdo@ee.washington.edu>
parents:
1504
diff
changeset
|
76 |
|
1498
520bc8457799
log rides along for free
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
77 |
/** |
520bc8457799
log rides along for free
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
78 |
* \ingroup logging |
520bc8457799
log rides along for free
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
79 |
* \param msg message to output |
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 |
* Generate logging output in the "log component" of the |
520bc8457799
log rides along for free
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
82 |
* 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
|
83 |
* a file implicitely generates out within the component |
520bc8457799
log rides along for free
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
84 |
* 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
|
85 |
* same file. |
520bc8457799
log rides along for free
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
86 |
*/ |
1506
3c8b23550e6a
disable log unless debug build
Craig Dowell <craigdo@ee.washington.edu>
parents:
1504
diff
changeset
|
87 |
|
3c8b23550e6a
disable log unless debug build
Craig Dowell <craigdo@ee.washington.edu>
parents:
1504
diff
changeset
|
88 |
#ifdef NS3_LOG_ENABLE |
3c8b23550e6a
disable log unless debug build
Craig Dowell <craigdo@ee.washington.edu>
parents:
1504
diff
changeset
|
89 |
|
3c8b23550e6a
disable log unless debug build
Craig Dowell <craigdo@ee.washington.edu>
parents:
1504
diff
changeset
|
90 |
#define NS_LOG(level, msg) \ |
3c8b23550e6a
disable log unless debug build
Craig Dowell <craigdo@ee.washington.edu>
parents:
1504
diff
changeset
|
91 |
do \ |
3c8b23550e6a
disable log unless debug build
Craig Dowell <craigdo@ee.washington.edu>
parents:
1504
diff
changeset
|
92 |
{ \ |
3c8b23550e6a
disable log unless debug build
Craig Dowell <craigdo@ee.washington.edu>
parents:
1504
diff
changeset
|
93 |
if (g_log.IsEnabled (level)) \ |
3c8b23550e6a
disable log unless debug build
Craig Dowell <craigdo@ee.washington.edu>
parents:
1504
diff
changeset
|
94 |
{ \ |
3c8b23550e6a
disable log unless debug build
Craig Dowell <craigdo@ee.washington.edu>
parents:
1504
diff
changeset
|
95 |
std::clog << __PRETTY_FUNCTION__ << " ==> " << \ |
3c8b23550e6a
disable log unless debug build
Craig Dowell <craigdo@ee.washington.edu>
parents:
1504
diff
changeset
|
96 |
msg << std::endl; \ |
3c8b23550e6a
disable log unless debug build
Craig Dowell <craigdo@ee.washington.edu>
parents:
1504
diff
changeset
|
97 |
} \ |
3c8b23550e6a
disable log unless debug build
Craig Dowell <craigdo@ee.washington.edu>
parents:
1504
diff
changeset
|
98 |
} \ |
1498
520bc8457799
log rides along for free
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
99 |
while (false) |
520bc8457799
log rides along for free
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
100 |
|
1504
36ecc970ba96
checkpoint debug to log
Craig Dowell <craigdo@ee.washington.edu>
parents:
1503
diff
changeset
|
101 |
#define NS_LOG_F(level) \ |
36ecc970ba96
checkpoint debug to log
Craig Dowell <craigdo@ee.washington.edu>
parents:
1503
diff
changeset
|
102 |
do \ |
36ecc970ba96
checkpoint debug to log
Craig Dowell <craigdo@ee.washington.edu>
parents:
1503
diff
changeset
|
103 |
{ \ |
36ecc970ba96
checkpoint debug to log
Craig Dowell <craigdo@ee.washington.edu>
parents:
1503
diff
changeset
|
104 |
if (g_log.IsEnabled (level)) \ |
36ecc970ba96
checkpoint debug to log
Craig Dowell <craigdo@ee.washington.edu>
parents:
1503
diff
changeset
|
105 |
{ \ |
36ecc970ba96
checkpoint debug to log
Craig Dowell <craigdo@ee.washington.edu>
parents:
1503
diff
changeset
|
106 |
std::clog << __PRETTY_FUNCTION__ << std::endl;\ |
36ecc970ba96
checkpoint debug to log
Craig Dowell <craigdo@ee.washington.edu>
parents:
1503
diff
changeset
|
107 |
} \ |
36ecc970ba96
checkpoint debug to log
Craig Dowell <craigdo@ee.washington.edu>
parents:
1503
diff
changeset
|
108 |
} \ |
36ecc970ba96
checkpoint debug to log
Craig Dowell <craigdo@ee.washington.edu>
parents:
1503
diff
changeset
|
109 |
while (false) |
36ecc970ba96
checkpoint debug to log
Craig Dowell <craigdo@ee.washington.edu>
parents:
1503
diff
changeset
|
110 |
|
1503
53dd8f414ba6
sorting out logging
Craig Dowell <craigdo@ee.washington.edu>
parents:
1498
diff
changeset
|
111 |
#define NS_LOG_ERROR(msg) \ |
53dd8f414ba6
sorting out logging
Craig Dowell <craigdo@ee.washington.edu>
parents:
1498
diff
changeset
|
112 |
NS_LOG(ns3::LOG_LEVEL_ERROR, msg) |
1498
520bc8457799
log rides along for free
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
113 |
|
520bc8457799
log rides along for free
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
114 |
#define NS_LOG_WARN(msg) \ |
1503
53dd8f414ba6
sorting out logging
Craig Dowell <craigdo@ee.washington.edu>
parents:
1498
diff
changeset
|
115 |
NS_LOG(ns3::LOG_LEVEL_WARN, msg) |
53dd8f414ba6
sorting out logging
Craig Dowell <craigdo@ee.washington.edu>
parents:
1498
diff
changeset
|
116 |
|
53dd8f414ba6
sorting out logging
Craig Dowell <craigdo@ee.washington.edu>
parents:
1498
diff
changeset
|
117 |
#define NS_LOG_DEBUG(msg) \ |
53dd8f414ba6
sorting out logging
Craig Dowell <craigdo@ee.washington.edu>
parents:
1498
diff
changeset
|
118 |
NS_LOG(ns3::LOG_LEVEL_DEBUG, msg) |
1498
520bc8457799
log rides along for free
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
119 |
|
1503
53dd8f414ba6
sorting out logging
Craig Dowell <craigdo@ee.washington.edu>
parents:
1498
diff
changeset
|
120 |
#define NS_LOG_INFO(msg) \ |
53dd8f414ba6
sorting out logging
Craig Dowell <craigdo@ee.washington.edu>
parents:
1498
diff
changeset
|
121 |
NS_LOG(ns3::LOG_LEVEL_INFO, msg) |
53dd8f414ba6
sorting out logging
Craig Dowell <craigdo@ee.washington.edu>
parents:
1498
diff
changeset
|
122 |
|
1504
36ecc970ba96
checkpoint debug to log
Craig Dowell <craigdo@ee.washington.edu>
parents:
1503
diff
changeset
|
123 |
#define NS_LOG_FUNCTION \ |
36ecc970ba96
checkpoint debug to log
Craig Dowell <craigdo@ee.washington.edu>
parents:
1503
diff
changeset
|
124 |
NS_LOG_F(ns3::LOG_LEVEL_FUNCTION) |
1498
520bc8457799
log rides along for free
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
125 |
|
1503
53dd8f414ba6
sorting out logging
Craig Dowell <craigdo@ee.washington.edu>
parents:
1498
diff
changeset
|
126 |
#define NS_LOG_PARAM(msg) \ |
53dd8f414ba6
sorting out logging
Craig Dowell <craigdo@ee.washington.edu>
parents:
1498
diff
changeset
|
127 |
NS_LOG(ns3::LOG_LEVEL_PARAM, msg) |
53dd8f414ba6
sorting out logging
Craig Dowell <craigdo@ee.washington.edu>
parents:
1498
diff
changeset
|
128 |
|
53dd8f414ba6
sorting out logging
Craig Dowell <craigdo@ee.washington.edu>
parents:
1498
diff
changeset
|
129 |
#define NS_LOG_LOGIC(msg) \ |
53dd8f414ba6
sorting out logging
Craig Dowell <craigdo@ee.washington.edu>
parents:
1498
diff
changeset
|
130 |
NS_LOG(ns3::LOG_LEVEL_LOGIC, msg) |
53dd8f414ba6
sorting out logging
Craig Dowell <craigdo@ee.washington.edu>
parents:
1498
diff
changeset
|
131 |
|
53dd8f414ba6
sorting out logging
Craig Dowell <craigdo@ee.washington.edu>
parents:
1498
diff
changeset
|
132 |
#define NS_LOG_ALL(msg) \ |
53dd8f414ba6
sorting out logging
Craig Dowell <craigdo@ee.washington.edu>
parents:
1498
diff
changeset
|
133 |
NS_LOG(ns3::LOG_LEVEL_ALL, msg) |
53dd8f414ba6
sorting out logging
Craig Dowell <craigdo@ee.washington.edu>
parents:
1498
diff
changeset
|
134 |
|
53dd8f414ba6
sorting out logging
Craig Dowell <craigdo@ee.washington.edu>
parents:
1498
diff
changeset
|
135 |
#define NS_LOG_UNCOND(msg) \ |
53dd8f414ba6
sorting out logging
Craig Dowell <craigdo@ee.washington.edu>
parents:
1498
diff
changeset
|
136 |
do \ |
53dd8f414ba6
sorting out logging
Craig Dowell <craigdo@ee.washington.edu>
parents:
1498
diff
changeset
|
137 |
{ \ |
53dd8f414ba6
sorting out logging
Craig Dowell <craigdo@ee.washington.edu>
parents:
1498
diff
changeset
|
138 |
std::clog << msg << std::endl; \ |
53dd8f414ba6
sorting out logging
Craig Dowell <craigdo@ee.washington.edu>
parents:
1498
diff
changeset
|
139 |
} \ |
1498
520bc8457799
log rides along for free
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
140 |
while (false) |
520bc8457799
log rides along for free
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
141 |
|
1506
3c8b23550e6a
disable log unless debug build
Craig Dowell <craigdo@ee.washington.edu>
parents:
1504
diff
changeset
|
142 |
#else |
3c8b23550e6a
disable log unless debug build
Craig Dowell <craigdo@ee.washington.edu>
parents:
1504
diff
changeset
|
143 |
|
3c8b23550e6a
disable log unless debug build
Craig Dowell <craigdo@ee.washington.edu>
parents:
1504
diff
changeset
|
144 |
#define NS_LOG(level, msg) |
3c8b23550e6a
disable log unless debug build
Craig Dowell <craigdo@ee.washington.edu>
parents:
1504
diff
changeset
|
145 |
#define NS_LOG_F(level) |
3c8b23550e6a
disable log unless debug build
Craig Dowell <craigdo@ee.washington.edu>
parents:
1504
diff
changeset
|
146 |
#define NS_LOG_ERROR(msg) |
3c8b23550e6a
disable log unless debug build
Craig Dowell <craigdo@ee.washington.edu>
parents:
1504
diff
changeset
|
147 |
#define NS_LOG_WARN(msg) |
3c8b23550e6a
disable log unless debug build
Craig Dowell <craigdo@ee.washington.edu>
parents:
1504
diff
changeset
|
148 |
#define NS_LOG_DEBUG(msg) |
3c8b23550e6a
disable log unless debug build
Craig Dowell <craigdo@ee.washington.edu>
parents:
1504
diff
changeset
|
149 |
#define NS_LOG_INFO(msg) |
3c8b23550e6a
disable log unless debug build
Craig Dowell <craigdo@ee.washington.edu>
parents:
1504
diff
changeset
|
150 |
#define NS_LOG_FUNCTION |
3c8b23550e6a
disable log unless debug build
Craig Dowell <craigdo@ee.washington.edu>
parents:
1504
diff
changeset
|
151 |
#define NS_LOG_PARAM(msg) |
3c8b23550e6a
disable log unless debug build
Craig Dowell <craigdo@ee.washington.edu>
parents:
1504
diff
changeset
|
152 |
#define NS_LOG_LOGIC(msg) |
3c8b23550e6a
disable log unless debug build
Craig Dowell <craigdo@ee.washington.edu>
parents:
1504
diff
changeset
|
153 |
#define NS_LOG_ALL(msg) |
3c8b23550e6a
disable log unless debug build
Craig Dowell <craigdo@ee.washington.edu>
parents:
1504
diff
changeset
|
154 |
#define NS_LOG_UNCOND(msg) |
3c8b23550e6a
disable log unless debug build
Craig Dowell <craigdo@ee.washington.edu>
parents:
1504
diff
changeset
|
155 |
|
3c8b23550e6a
disable log unless debug build
Craig Dowell <craigdo@ee.washington.edu>
parents:
1504
diff
changeset
|
156 |
#endif |
3c8b23550e6a
disable log unless debug build
Craig Dowell <craigdo@ee.washington.edu>
parents:
1504
diff
changeset
|
157 |
|
1498
520bc8457799
log rides along for free
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
158 |
namespace ns3 { |
520bc8457799
log rides along for free
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
159 |
|
1506
3c8b23550e6a
disable log unless debug build
Craig Dowell <craigdo@ee.washington.edu>
parents:
1504
diff
changeset
|
160 |
#ifdef NS3_LOG_ENABLE |
3c8b23550e6a
disable log unless debug build
Craig Dowell <craigdo@ee.washington.edu>
parents:
1504
diff
changeset
|
161 |
|
1498
520bc8457799
log rides along for free
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
162 |
enum LogLevel { |
1503
53dd8f414ba6
sorting out logging
Craig Dowell <craigdo@ee.washington.edu>
parents:
1498
diff
changeset
|
163 |
LOG_LEVEL_ERROR = 1<<0, // serious error messages only |
53dd8f414ba6
sorting out logging
Craig Dowell <craigdo@ee.washington.edu>
parents:
1498
diff
changeset
|
164 |
LOG_LEVEL_WARN = 1<<1, // add warning messages |
53dd8f414ba6
sorting out logging
Craig Dowell <craigdo@ee.washington.edu>
parents:
1498
diff
changeset
|
165 |
LOG_LEVEL_DEBUG = 1<<2, // add rare ad-hoc debug messages |
53dd8f414ba6
sorting out logging
Craig Dowell <craigdo@ee.washington.edu>
parents:
1498
diff
changeset
|
166 |
LOG_LEVEL_INFO = 1<<3, // add informational messages (e.g., banners) |
53dd8f414ba6
sorting out logging
Craig Dowell <craigdo@ee.washington.edu>
parents:
1498
diff
changeset
|
167 |
LOG_LEVEL_FUNCTION = 1<<4, // add function tracing |
53dd8f414ba6
sorting out logging
Craig Dowell <craigdo@ee.washington.edu>
parents:
1498
diff
changeset
|
168 |
LOG_LEVEL_PARAM = 1<<5, // add parameters to functions |
53dd8f414ba6
sorting out logging
Craig Dowell <craigdo@ee.washington.edu>
parents:
1498
diff
changeset
|
169 |
LOG_LEVEL_LOGIC = 1<<6, // add control flow tracing within functions |
53dd8f414ba6
sorting out logging
Craig Dowell <craigdo@ee.washington.edu>
parents:
1498
diff
changeset
|
170 |
LOG_LEVEL_ALL = 1<<30 // print everything |
1498
520bc8457799
log rides along for free
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
171 |
}; |
520bc8457799
log rides along for free
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
172 |
|
1506
3c8b23550e6a
disable log unless debug build
Craig Dowell <craigdo@ee.washington.edu>
parents:
1504
diff
changeset
|
173 |
#endif |
3c8b23550e6a
disable log unless debug build
Craig Dowell <craigdo@ee.washington.edu>
parents:
1504
diff
changeset
|
174 |
|
1498
520bc8457799
log rides along for free
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
175 |
/** |
520bc8457799
log rides along for free
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
176 |
* \param name a log component name |
520bc8457799
log rides along for free
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
177 |
* \ingroup logging |
520bc8457799
log rides along for free
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
178 |
* |
520bc8457799
log rides along for free
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
179 |
* Enable the logging output associated with that log component. |
520bc8457799
log rides along for free
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
180 |
* 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
|
181 |
* to ns3::LogComponentDisable. |
520bc8457799
log rides along for free
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
182 |
*/ |
1506
3c8b23550e6a
disable log unless debug build
Craig Dowell <craigdo@ee.washington.edu>
parents:
1504
diff
changeset
|
183 |
#ifdef NS3_LOG_ENABLE |
1498
520bc8457799
log rides along for free
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
184 |
void LogComponentEnable (char const *name, enum LogLevel level); |
1506
3c8b23550e6a
disable log unless debug build
Craig Dowell <craigdo@ee.washington.edu>
parents:
1504
diff
changeset
|
185 |
#else |
3c8b23550e6a
disable log unless debug build
Craig Dowell <craigdo@ee.washington.edu>
parents:
1504
diff
changeset
|
186 |
#define LogComponentEnable(a,b) |
3c8b23550e6a
disable log unless debug build
Craig Dowell <craigdo@ee.washington.edu>
parents:
1504
diff
changeset
|
187 |
#endif |
1498
520bc8457799
log rides along for free
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
188 |
|
520bc8457799
log rides along for free
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
189 |
/** |
520bc8457799
log rides along for free
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
190 |
* \param name a log component name |
520bc8457799
log rides along for free
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
191 |
* \ingroup logging |
520bc8457799
log rides along for free
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
192 |
* |
520bc8457799
log rides along for free
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
193 |
* Disable the logging output associated with that log component. |
520bc8457799
log rides along for free
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
194 |
* 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
|
195 |
* to ns3::LogComponentEnable. |
520bc8457799
log rides along for free
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
196 |
*/ |
1506
3c8b23550e6a
disable log unless debug build
Craig Dowell <craigdo@ee.washington.edu>
parents:
1504
diff
changeset
|
197 |
#ifdef NS3_LOG_ENABLE |
1498
520bc8457799
log rides along for free
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
198 |
void LogComponentDisable (char const *name, enum LogLevel level); |
1506
3c8b23550e6a
disable log unless debug build
Craig Dowell <craigdo@ee.washington.edu>
parents:
1504
diff
changeset
|
199 |
#else |
3c8b23550e6a
disable log unless debug build
Craig Dowell <craigdo@ee.washington.edu>
parents:
1504
diff
changeset
|
200 |
#define LogComponentDisable(a,b) |
3c8b23550e6a
disable log unless debug build
Craig Dowell <craigdo@ee.washington.edu>
parents:
1504
diff
changeset
|
201 |
#endif |
1498
520bc8457799
log rides along for free
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
202 |
|
520bc8457799
log rides along for free
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
203 |
/** |
520bc8457799
log rides along for free
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
204 |
* \ingroup logging |
520bc8457799
log rides along for free
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
205 |
* |
520bc8457799
log rides along for free
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
206 |
* Print the list of logging messages available. |
520bc8457799
log rides along for free
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
207 |
* The output of this function can be obtained by setting |
520bc8457799
log rides along for free
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
208 |
* the NS_LOG environment variable to the special value |
520bc8457799
log rides along for free
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
209 |
* 'print-list'. |
520bc8457799
log rides along for free
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
210 |
* |
520bc8457799
log rides along for free
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
211 |
* For example: NS_LOG=print-list |
520bc8457799
log rides along for free
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
212 |
*/ |
1506
3c8b23550e6a
disable log unless debug build
Craig Dowell <craigdo@ee.washington.edu>
parents:
1504
diff
changeset
|
213 |
#ifdef NS3_LOG_ENABLE |
1498
520bc8457799
log rides along for free
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
214 |
void LogComponentPrintList (void); |
1506
3c8b23550e6a
disable log unless debug build
Craig Dowell <craigdo@ee.washington.edu>
parents:
1504
diff
changeset
|
215 |
#else |
3c8b23550e6a
disable log unless debug build
Craig Dowell <craigdo@ee.washington.edu>
parents:
1504
diff
changeset
|
216 |
#define LogComponentPrintList() |
3c8b23550e6a
disable log unless debug build
Craig Dowell <craigdo@ee.washington.edu>
parents:
1504
diff
changeset
|
217 |
#endif |
3c8b23550e6a
disable log unless debug build
Craig Dowell <craigdo@ee.washington.edu>
parents:
1504
diff
changeset
|
218 |
|
3c8b23550e6a
disable log unless debug build
Craig Dowell <craigdo@ee.washington.edu>
parents:
1504
diff
changeset
|
219 |
#ifdef NS3_LOG_ENABLE |
1498
520bc8457799
log rides along for free
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
220 |
|
520bc8457799
log rides along for free
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
221 |
class LogComponent { |
520bc8457799
log rides along for free
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
222 |
public: |
520bc8457799
log rides along for free
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
223 |
LogComponent (char const *name); |
520bc8457799
log rides along for free
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
224 |
bool IsEnabled (enum LogLevel level) const; |
520bc8457799
log rides along for free
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
225 |
bool IsNoneEnabled (void) const; |
520bc8457799
log rides along for free
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
226 |
void Enable (enum LogLevel level); |
520bc8457799
log rides along for free
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
227 |
void Disable (enum LogLevel level); |
520bc8457799
log rides along for free
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
228 |
private: |
1503
53dd8f414ba6
sorting out logging
Craig Dowell <craigdo@ee.washington.edu>
parents:
1498
diff
changeset
|
229 |
int32_t m_levels; |
1498
520bc8457799
log rides along for free
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
230 |
}; |
520bc8457799
log rides along for free
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
231 |
|
1506
3c8b23550e6a
disable log unless debug build
Craig Dowell <craigdo@ee.washington.edu>
parents:
1504
diff
changeset
|
232 |
#endif |
3c8b23550e6a
disable log unless debug build
Craig Dowell <craigdo@ee.washington.edu>
parents:
1504
diff
changeset
|
233 |
|
1498
520bc8457799
log rides along for free
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
234 |
} // namespace ns3 |
520bc8457799
log rides along for free
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
235 |
|
1506
3c8b23550e6a
disable log unless debug build
Craig Dowell <craigdo@ee.washington.edu>
parents:
1504
diff
changeset
|
236 |
#endif // __LOG_H__ |