author | Tom Henderson <tomh@tomh.org> |
Sun, 22 May 2011 22:28:15 -0700 | |
changeset 7252 | c8200621e252 |
parent 7169 | 358f71a624d8 |
child 7256 | b04ba6772f8c |
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 |
*/ |
3483
7ce1353e63ba
Make the LogComponent* utility functions available for optimized builds as well, albeit as noops. Closes #258.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
3005
diff
changeset
|
20 |
#include "log.h" |
1506
3c8b23550e6a
disable log unless debug build
Craig Dowell <craigdo@ee.washington.edu>
parents:
1503
diff
changeset
|
21 |
|
1498
520bc8457799
log rides along for free
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
22 |
#include <list> |
520bc8457799
log rides along for free
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
23 |
#include <utility> |
520bc8457799
log rides along for free
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
24 |
#include <iostream> |
520bc8457799
log rides along for free
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
25 |
#include "assert.h" |
520bc8457799
log rides along for free
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
26 |
#include "ns3/core-config.h" |
520bc8457799
log rides along for free
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
27 |
#include "fatal-error.h" |
520bc8457799
log rides along for free
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
28 |
|
520bc8457799
log rides along for free
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
29 |
#ifdef HAVE_STDLIB_H |
520bc8457799
log rides along for free
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
30 |
#include <stdlib.h> |
520bc8457799
log rides along for free
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
31 |
#endif |
520bc8457799
log rides along for free
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
32 |
|
520bc8457799
log rides along for free
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
33 |
namespace ns3 { |
520bc8457799
log rides along for free
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
34 |
|
2979
3d39dd617b8d
add time logging support
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2976
diff
changeset
|
35 |
LogTimePrinter g_logTimePrinter = 0; |
5522
0d1a06c5b285
Print node context in log messages
Guillaume Seguin <guillaume@segu.in>
parents:
3483
diff
changeset
|
36 |
LogNodePrinter g_logNodePrinter = 0; |
2979
3d39dd617b8d
add time logging support
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2976
diff
changeset
|
37 |
|
1498
520bc8457799
log rides along for free
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
38 |
typedef std::list<std::pair <std::string, LogComponent *> > ComponentList; |
520bc8457799
log rides along for free
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
39 |
typedef std::list<std::pair <std::string, LogComponent *> >::iterator ComponentListI; |
520bc8457799
log rides along for free
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
40 |
|
1861
5bc0b0d8d620
bug 91: add print-list support to NS_LOG env var.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1828
diff
changeset
|
41 |
static class PrintList |
5bc0b0d8d620
bug 91: add print-list support to NS_LOG env var.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1828
diff
changeset
|
42 |
{ |
5bc0b0d8d620
bug 91: add print-list support to NS_LOG env var.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1828
diff
changeset
|
43 |
public: |
5bc0b0d8d620
bug 91: add print-list support to NS_LOG env var.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1828
diff
changeset
|
44 |
PrintList (); |
5bc0b0d8d620
bug 91: add print-list support to NS_LOG env var.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1828
diff
changeset
|
45 |
} g_printList; |
5bc0b0d8d620
bug 91: add print-list support to NS_LOG env var.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1828
diff
changeset
|
46 |
|
1498
520bc8457799
log rides along for free
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
47 |
static |
520bc8457799
log rides along for free
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
48 |
ComponentList *GetComponentList (void) |
520bc8457799
log rides along for free
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
49 |
{ |
520bc8457799
log rides along for free
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
50 |
static ComponentList components; |
520bc8457799
log rides along for free
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
51 |
return &components; |
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 |
|
1861
5bc0b0d8d620
bug 91: add print-list support to NS_LOG env var.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1828
diff
changeset
|
54 |
|
5bc0b0d8d620
bug 91: add print-list support to NS_LOG env var.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1828
diff
changeset
|
55 |
|
5bc0b0d8d620
bug 91: add print-list support to NS_LOG env var.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1828
diff
changeset
|
56 |
PrintList::PrintList () |
5bc0b0d8d620
bug 91: add print-list support to NS_LOG env var.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1828
diff
changeset
|
57 |
{ |
5bc0b0d8d620
bug 91: add print-list support to NS_LOG env var.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1828
diff
changeset
|
58 |
#ifdef HAVE_GETENV |
5bc0b0d8d620
bug 91: add print-list support to NS_LOG env var.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1828
diff
changeset
|
59 |
char *envVar = getenv("NS_LOG"); |
5bc0b0d8d620
bug 91: add print-list support to NS_LOG env var.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1828
diff
changeset
|
60 |
if (envVar == 0) |
5bc0b0d8d620
bug 91: add print-list support to NS_LOG env var.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1828
diff
changeset
|
61 |
{ |
5bc0b0d8d620
bug 91: add print-list support to NS_LOG env var.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1828
diff
changeset
|
62 |
return; |
5bc0b0d8d620
bug 91: add print-list support to NS_LOG env var.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1828
diff
changeset
|
63 |
} |
5bc0b0d8d620
bug 91: add print-list support to NS_LOG env var.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1828
diff
changeset
|
64 |
std::string env = envVar; |
5bc0b0d8d620
bug 91: add print-list support to NS_LOG env var.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1828
diff
changeset
|
65 |
std::string::size_type cur = 0; |
5bc0b0d8d620
bug 91: add print-list support to NS_LOG env var.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1828
diff
changeset
|
66 |
std::string::size_type next = 0; |
5bc0b0d8d620
bug 91: add print-list support to NS_LOG env var.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1828
diff
changeset
|
67 |
while (next != std::string::npos) |
5bc0b0d8d620
bug 91: add print-list support to NS_LOG env var.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1828
diff
changeset
|
68 |
{ |
2982
a7e3e54c7e94
change NS_LOG= syntax and default behavior to be more useful by default.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2979
diff
changeset
|
69 |
next = env.find_first_of (":", cur); |
1861
5bc0b0d8d620
bug 91: add print-list support to NS_LOG env var.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1828
diff
changeset
|
70 |
std::string tmp = std::string (env, cur, next-cur); |
5bc0b0d8d620
bug 91: add print-list support to NS_LOG env var.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1828
diff
changeset
|
71 |
if (tmp == "print-list") |
5bc0b0d8d620
bug 91: add print-list support to NS_LOG env var.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1828
diff
changeset
|
72 |
{ |
5bc0b0d8d620
bug 91: add print-list support to NS_LOG env var.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1828
diff
changeset
|
73 |
LogComponentPrintList (); |
5bc0b0d8d620
bug 91: add print-list support to NS_LOG env var.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1828
diff
changeset
|
74 |
exit (0); |
5bc0b0d8d620
bug 91: add print-list support to NS_LOG env var.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1828
diff
changeset
|
75 |
break; |
5bc0b0d8d620
bug 91: add print-list support to NS_LOG env var.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1828
diff
changeset
|
76 |
} |
5bc0b0d8d620
bug 91: add print-list support to NS_LOG env var.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1828
diff
changeset
|
77 |
cur = next + 1; |
5bc0b0d8d620
bug 91: add print-list support to NS_LOG env var.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1828
diff
changeset
|
78 |
} |
7169
358f71a624d8
core coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents:
7017
diff
changeset
|
79 |
#endif |
1861
5bc0b0d8d620
bug 91: add print-list support to NS_LOG env var.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1828
diff
changeset
|
80 |
} |
5bc0b0d8d620
bug 91: add print-list support to NS_LOG env var.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1828
diff
changeset
|
81 |
|
5bc0b0d8d620
bug 91: add print-list support to NS_LOG env var.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1828
diff
changeset
|
82 |
|
1783
36472385a1cc
NS_LOG parsing changes to address bug 91
Craig Dowell <craigdo@ee.washington.edu>
parents:
1775
diff
changeset
|
83 |
LogComponent::LogComponent (char const * name) |
36472385a1cc
NS_LOG parsing changes to address bug 91
Craig Dowell <craigdo@ee.washington.edu>
parents:
1775
diff
changeset
|
84 |
: m_levels (0), m_name (name) |
1498
520bc8457799
log rides along for free
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
85 |
{ |
1783
36472385a1cc
NS_LOG parsing changes to address bug 91
Craig Dowell <craigdo@ee.washington.edu>
parents:
1775
diff
changeset
|
86 |
EnvVarCheck (name); |
36472385a1cc
NS_LOG parsing changes to address bug 91
Craig Dowell <craigdo@ee.washington.edu>
parents:
1775
diff
changeset
|
87 |
|
36472385a1cc
NS_LOG parsing changes to address bug 91
Craig Dowell <craigdo@ee.washington.edu>
parents:
1775
diff
changeset
|
88 |
ComponentList *components = GetComponentList (); |
36472385a1cc
NS_LOG parsing changes to address bug 91
Craig Dowell <craigdo@ee.washington.edu>
parents:
1775
diff
changeset
|
89 |
for (ComponentListI i = components->begin (); |
36472385a1cc
NS_LOG parsing changes to address bug 91
Craig Dowell <craigdo@ee.washington.edu>
parents:
1775
diff
changeset
|
90 |
i != components->end (); |
36472385a1cc
NS_LOG parsing changes to address bug 91
Craig Dowell <craigdo@ee.washington.edu>
parents:
1775
diff
changeset
|
91 |
i++) |
1498
520bc8457799
log rides along for free
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
92 |
{ |
2809
30e451c21f60
improve warning output
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1862
diff
changeset
|
93 |
if (i->first == name) |
30e451c21f60
improve warning output
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1862
diff
changeset
|
94 |
{ |
30e451c21f60
improve warning output
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1862
diff
changeset
|
95 |
NS_FATAL_ERROR ("Log component \""<<name<<"\" has already been registered once."); |
30e451c21f60
improve warning output
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1862
diff
changeset
|
96 |
} |
1498
520bc8457799
log rides along for free
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
97 |
} |
1783
36472385a1cc
NS_LOG parsing changes to address bug 91
Craig Dowell <craigdo@ee.washington.edu>
parents:
1775
diff
changeset
|
98 |
components->push_back (std::make_pair (name, this)); |
36472385a1cc
NS_LOG parsing changes to address bug 91
Craig Dowell <craigdo@ee.washington.edu>
parents:
1775
diff
changeset
|
99 |
} |
1775
5abf6f0d1eca
deal with static constructor problem
Craig Dowell <craigdo@ee.washington.edu>
parents:
1773
diff
changeset
|
100 |
|
1783
36472385a1cc
NS_LOG parsing changes to address bug 91
Craig Dowell <craigdo@ee.washington.edu>
parents:
1775
diff
changeset
|
101 |
void |
36472385a1cc
NS_LOG parsing changes to address bug 91
Craig Dowell <craigdo@ee.washington.edu>
parents:
1775
diff
changeset
|
102 |
LogComponent::EnvVarCheck (char const * name) |
36472385a1cc
NS_LOG parsing changes to address bug 91
Craig Dowell <craigdo@ee.washington.edu>
parents:
1775
diff
changeset
|
103 |
{ |
1498
520bc8457799
log rides along for free
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
104 |
#ifdef HAVE_GETENV |
520bc8457799
log rides along for free
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
105 |
char *envVar = getenv("NS_LOG"); |
520bc8457799
log rides along for free
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
106 |
if (envVar == 0) |
520bc8457799
log rides along for free
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
107 |
{ |
520bc8457799
log rides along for free
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
108 |
return; |
520bc8457799
log rides along for free
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
109 |
} |
520bc8457799
log rides along for free
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
110 |
std::string env = envVar; |
1783
36472385a1cc
NS_LOG parsing changes to address bug 91
Craig Dowell <craigdo@ee.washington.edu>
parents:
1775
diff
changeset
|
111 |
std::string myName = name; |
36472385a1cc
NS_LOG parsing changes to address bug 91
Craig Dowell <craigdo@ee.washington.edu>
parents:
1775
diff
changeset
|
112 |
|
1498
520bc8457799
log rides along for free
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
113 |
std::string::size_type cur = 0; |
520bc8457799
log rides along for free
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
114 |
std::string::size_type next = 0; |
1862
3627401f90cf
simplify the parsing logic and remove buggy comment and code.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1861
diff
changeset
|
115 |
while (next != std::string::npos) |
1498
520bc8457799
log rides along for free
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
116 |
{ |
2982
a7e3e54c7e94
change NS_LOG= syntax and default behavior to be more useful by default.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2979
diff
changeset
|
117 |
next = env.find_first_of (":", cur); |
1862
3627401f90cf
simplify the parsing logic and remove buggy comment and code.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1861
diff
changeset
|
118 |
std::string tmp = std::string (env, cur, next-cur); |
1498
520bc8457799
log rides along for free
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
119 |
std::string::size_type equal = tmp.find ("="); |
520bc8457799
log rides along for free
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
120 |
std::string component; |
520bc8457799
log rides along for free
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
121 |
if (equal == std::string::npos) |
520bc8457799
log rides along for free
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
122 |
{ |
520bc8457799
log rides along for free
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
123 |
component = tmp; |
1783
36472385a1cc
NS_LOG parsing changes to address bug 91
Craig Dowell <craigdo@ee.washington.edu>
parents:
1775
diff
changeset
|
124 |
if (component == myName || component == "*") |
36472385a1cc
NS_LOG parsing changes to address bug 91
Craig Dowell <craigdo@ee.washington.edu>
parents:
1775
diff
changeset
|
125 |
{ |
5522
0d1a06c5b285
Print node context in log messages
Guillaume Seguin <guillaume@segu.in>
parents:
3483
diff
changeset
|
126 |
int level = LOG_ALL | LOG_PREFIX_TIME | LOG_PREFIX_FUNC | LOG_PREFIX_NODE; |
2982
a7e3e54c7e94
change NS_LOG= syntax and default behavior to be more useful by default.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2979
diff
changeset
|
127 |
Enable ((enum LogLevel)level); |
1783
36472385a1cc
NS_LOG parsing changes to address bug 91
Craig Dowell <craigdo@ee.washington.edu>
parents:
1775
diff
changeset
|
128 |
return; |
36472385a1cc
NS_LOG parsing changes to address bug 91
Craig Dowell <craigdo@ee.washington.edu>
parents:
1775
diff
changeset
|
129 |
} |
1498
520bc8457799
log rides along for free
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
130 |
} |
520bc8457799
log rides along for free
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
131 |
else |
520bc8457799
log rides along for free
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
132 |
{ |
520bc8457799
log rides along for free
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
133 |
component = tmp.substr (0, equal); |
1783
36472385a1cc
NS_LOG parsing changes to address bug 91
Craig Dowell <craigdo@ee.washington.edu>
parents:
1775
diff
changeset
|
134 |
if (component == myName || component == "*") |
1498
520bc8457799
log rides along for free
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
135 |
{ |
1783
36472385a1cc
NS_LOG parsing changes to address bug 91
Craig Dowell <craigdo@ee.washington.edu>
parents:
1775
diff
changeset
|
136 |
int level = 0; |
36472385a1cc
NS_LOG parsing changes to address bug 91
Craig Dowell <craigdo@ee.washington.edu>
parents:
1775
diff
changeset
|
137 |
std::string::size_type cur_lev; |
36472385a1cc
NS_LOG parsing changes to address bug 91
Craig Dowell <craigdo@ee.washington.edu>
parents:
1775
diff
changeset
|
138 |
std::string::size_type next_lev = equal; |
36472385a1cc
NS_LOG parsing changes to address bug 91
Craig Dowell <craigdo@ee.washington.edu>
parents:
1775
diff
changeset
|
139 |
do |
1503
53dd8f414ba6
sorting out logging
Craig Dowell <craigdo@ee.washington.edu>
parents:
1498
diff
changeset
|
140 |
{ |
1783
36472385a1cc
NS_LOG parsing changes to address bug 91
Craig Dowell <craigdo@ee.washington.edu>
parents:
1775
diff
changeset
|
141 |
cur_lev = next_lev + 1; |
36472385a1cc
NS_LOG parsing changes to address bug 91
Craig Dowell <craigdo@ee.washington.edu>
parents:
1775
diff
changeset
|
142 |
next_lev = tmp.find ("|", cur_lev); |
36472385a1cc
NS_LOG parsing changes to address bug 91
Craig Dowell <craigdo@ee.washington.edu>
parents:
1775
diff
changeset
|
143 |
std::string lev = tmp.substr (cur_lev, next_lev - cur_lev); |
36472385a1cc
NS_LOG parsing changes to address bug 91
Craig Dowell <craigdo@ee.washington.edu>
parents:
1775
diff
changeset
|
144 |
if (lev == "error") |
36472385a1cc
NS_LOG parsing changes to address bug 91
Craig Dowell <craigdo@ee.washington.edu>
parents:
1775
diff
changeset
|
145 |
{ |
36472385a1cc
NS_LOG parsing changes to address bug 91
Craig Dowell <craigdo@ee.washington.edu>
parents:
1775
diff
changeset
|
146 |
level |= LOG_ERROR; |
36472385a1cc
NS_LOG parsing changes to address bug 91
Craig Dowell <craigdo@ee.washington.edu>
parents:
1775
diff
changeset
|
147 |
} |
36472385a1cc
NS_LOG parsing changes to address bug 91
Craig Dowell <craigdo@ee.washington.edu>
parents:
1775
diff
changeset
|
148 |
else if (lev == "warn") |
36472385a1cc
NS_LOG parsing changes to address bug 91
Craig Dowell <craigdo@ee.washington.edu>
parents:
1775
diff
changeset
|
149 |
{ |
36472385a1cc
NS_LOG parsing changes to address bug 91
Craig Dowell <craigdo@ee.washington.edu>
parents:
1775
diff
changeset
|
150 |
level |= LOG_WARN; |
36472385a1cc
NS_LOG parsing changes to address bug 91
Craig Dowell <craigdo@ee.washington.edu>
parents:
1775
diff
changeset
|
151 |
} |
36472385a1cc
NS_LOG parsing changes to address bug 91
Craig Dowell <craigdo@ee.washington.edu>
parents:
1775
diff
changeset
|
152 |
else if (lev == "debug") |
36472385a1cc
NS_LOG parsing changes to address bug 91
Craig Dowell <craigdo@ee.washington.edu>
parents:
1775
diff
changeset
|
153 |
{ |
36472385a1cc
NS_LOG parsing changes to address bug 91
Craig Dowell <craigdo@ee.washington.edu>
parents:
1775
diff
changeset
|
154 |
level |= LOG_DEBUG; |
36472385a1cc
NS_LOG parsing changes to address bug 91
Craig Dowell <craigdo@ee.washington.edu>
parents:
1775
diff
changeset
|
155 |
} |
36472385a1cc
NS_LOG parsing changes to address bug 91
Craig Dowell <craigdo@ee.washington.edu>
parents:
1775
diff
changeset
|
156 |
else if (lev == "info") |
36472385a1cc
NS_LOG parsing changes to address bug 91
Craig Dowell <craigdo@ee.washington.edu>
parents:
1775
diff
changeset
|
157 |
{ |
36472385a1cc
NS_LOG parsing changes to address bug 91
Craig Dowell <craigdo@ee.washington.edu>
parents:
1775
diff
changeset
|
158 |
level |= LOG_INFO; |
36472385a1cc
NS_LOG parsing changes to address bug 91
Craig Dowell <craigdo@ee.washington.edu>
parents:
1775
diff
changeset
|
159 |
} |
36472385a1cc
NS_LOG parsing changes to address bug 91
Craig Dowell <craigdo@ee.washington.edu>
parents:
1775
diff
changeset
|
160 |
else if (lev == "function") |
36472385a1cc
NS_LOG parsing changes to address bug 91
Craig Dowell <craigdo@ee.washington.edu>
parents:
1775
diff
changeset
|
161 |
{ |
36472385a1cc
NS_LOG parsing changes to address bug 91
Craig Dowell <craigdo@ee.washington.edu>
parents:
1775
diff
changeset
|
162 |
level |= LOG_FUNCTION; |
36472385a1cc
NS_LOG parsing changes to address bug 91
Craig Dowell <craigdo@ee.washington.edu>
parents:
1775
diff
changeset
|
163 |
} |
36472385a1cc
NS_LOG parsing changes to address bug 91
Craig Dowell <craigdo@ee.washington.edu>
parents:
1775
diff
changeset
|
164 |
else if (lev == "logic") |
36472385a1cc
NS_LOG parsing changes to address bug 91
Craig Dowell <craigdo@ee.washington.edu>
parents:
1775
diff
changeset
|
165 |
{ |
36472385a1cc
NS_LOG parsing changes to address bug 91
Craig Dowell <craigdo@ee.washington.edu>
parents:
1775
diff
changeset
|
166 |
level |= LOG_LOGIC; |
36472385a1cc
NS_LOG parsing changes to address bug 91
Craig Dowell <craigdo@ee.washington.edu>
parents:
1775
diff
changeset
|
167 |
} |
36472385a1cc
NS_LOG parsing changes to address bug 91
Craig Dowell <craigdo@ee.washington.edu>
parents:
1775
diff
changeset
|
168 |
else if (lev == "all") |
36472385a1cc
NS_LOG parsing changes to address bug 91
Craig Dowell <craigdo@ee.washington.edu>
parents:
1775
diff
changeset
|
169 |
{ |
36472385a1cc
NS_LOG parsing changes to address bug 91
Craig Dowell <craigdo@ee.washington.edu>
parents:
1775
diff
changeset
|
170 |
level |= LOG_ALL; |
36472385a1cc
NS_LOG parsing changes to address bug 91
Craig Dowell <craigdo@ee.washington.edu>
parents:
1775
diff
changeset
|
171 |
} |
2979
3d39dd617b8d
add time logging support
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2976
diff
changeset
|
172 |
else if (lev == "prefix_func") |
1783
36472385a1cc
NS_LOG parsing changes to address bug 91
Craig Dowell <craigdo@ee.washington.edu>
parents:
1775
diff
changeset
|
173 |
{ |
2979
3d39dd617b8d
add time logging support
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2976
diff
changeset
|
174 |
level |= LOG_PREFIX_FUNC; |
3d39dd617b8d
add time logging support
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2976
diff
changeset
|
175 |
} |
3d39dd617b8d
add time logging support
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2976
diff
changeset
|
176 |
else if (lev == "prefix_time") |
3d39dd617b8d
add time logging support
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2976
diff
changeset
|
177 |
{ |
3d39dd617b8d
add time logging support
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2976
diff
changeset
|
178 |
level |= LOG_PREFIX_TIME; |
1783
36472385a1cc
NS_LOG parsing changes to address bug 91
Craig Dowell <craigdo@ee.washington.edu>
parents:
1775
diff
changeset
|
179 |
} |
5522
0d1a06c5b285
Print node context in log messages
Guillaume Seguin <guillaume@segu.in>
parents:
3483
diff
changeset
|
180 |
else if (lev == "prefix_node") |
0d1a06c5b285
Print node context in log messages
Guillaume Seguin <guillaume@segu.in>
parents:
3483
diff
changeset
|
181 |
{ |
0d1a06c5b285
Print node context in log messages
Guillaume Seguin <guillaume@segu.in>
parents:
3483
diff
changeset
|
182 |
level |= LOG_PREFIX_NODE; |
0d1a06c5b285
Print node context in log messages
Guillaume Seguin <guillaume@segu.in>
parents:
3483
diff
changeset
|
183 |
} |
1783
36472385a1cc
NS_LOG parsing changes to address bug 91
Craig Dowell <craigdo@ee.washington.edu>
parents:
1775
diff
changeset
|
184 |
else if (lev == "level_error") |
36472385a1cc
NS_LOG parsing changes to address bug 91
Craig Dowell <craigdo@ee.washington.edu>
parents:
1775
diff
changeset
|
185 |
{ |
36472385a1cc
NS_LOG parsing changes to address bug 91
Craig Dowell <craigdo@ee.washington.edu>
parents:
1775
diff
changeset
|
186 |
level |= LOG_LEVEL_ERROR; |
36472385a1cc
NS_LOG parsing changes to address bug 91
Craig Dowell <craigdo@ee.washington.edu>
parents:
1775
diff
changeset
|
187 |
} |
36472385a1cc
NS_LOG parsing changes to address bug 91
Craig Dowell <craigdo@ee.washington.edu>
parents:
1775
diff
changeset
|
188 |
else if (lev == "level_warn") |
36472385a1cc
NS_LOG parsing changes to address bug 91
Craig Dowell <craigdo@ee.washington.edu>
parents:
1775
diff
changeset
|
189 |
{ |
36472385a1cc
NS_LOG parsing changes to address bug 91
Craig Dowell <craigdo@ee.washington.edu>
parents:
1775
diff
changeset
|
190 |
level |= LOG_LEVEL_WARN; |
36472385a1cc
NS_LOG parsing changes to address bug 91
Craig Dowell <craigdo@ee.washington.edu>
parents:
1775
diff
changeset
|
191 |
} |
36472385a1cc
NS_LOG parsing changes to address bug 91
Craig Dowell <craigdo@ee.washington.edu>
parents:
1775
diff
changeset
|
192 |
else if (lev == "level_debug") |
36472385a1cc
NS_LOG parsing changes to address bug 91
Craig Dowell <craigdo@ee.washington.edu>
parents:
1775
diff
changeset
|
193 |
{ |
36472385a1cc
NS_LOG parsing changes to address bug 91
Craig Dowell <craigdo@ee.washington.edu>
parents:
1775
diff
changeset
|
194 |
level |= LOG_LEVEL_DEBUG; |
36472385a1cc
NS_LOG parsing changes to address bug 91
Craig Dowell <craigdo@ee.washington.edu>
parents:
1775
diff
changeset
|
195 |
} |
36472385a1cc
NS_LOG parsing changes to address bug 91
Craig Dowell <craigdo@ee.washington.edu>
parents:
1775
diff
changeset
|
196 |
else if (lev == "level_info") |
36472385a1cc
NS_LOG parsing changes to address bug 91
Craig Dowell <craigdo@ee.washington.edu>
parents:
1775
diff
changeset
|
197 |
{ |
36472385a1cc
NS_LOG parsing changes to address bug 91
Craig Dowell <craigdo@ee.washington.edu>
parents:
1775
diff
changeset
|
198 |
level |= LOG_LEVEL_INFO; |
36472385a1cc
NS_LOG parsing changes to address bug 91
Craig Dowell <craigdo@ee.washington.edu>
parents:
1775
diff
changeset
|
199 |
} |
36472385a1cc
NS_LOG parsing changes to address bug 91
Craig Dowell <craigdo@ee.washington.edu>
parents:
1775
diff
changeset
|
200 |
else if (lev == "level_function") |
36472385a1cc
NS_LOG parsing changes to address bug 91
Craig Dowell <craigdo@ee.washington.edu>
parents:
1775
diff
changeset
|
201 |
{ |
36472385a1cc
NS_LOG parsing changes to address bug 91
Craig Dowell <craigdo@ee.washington.edu>
parents:
1775
diff
changeset
|
202 |
level |= LOG_LEVEL_FUNCTION; |
36472385a1cc
NS_LOG parsing changes to address bug 91
Craig Dowell <craigdo@ee.washington.edu>
parents:
1775
diff
changeset
|
203 |
} |
36472385a1cc
NS_LOG parsing changes to address bug 91
Craig Dowell <craigdo@ee.washington.edu>
parents:
1775
diff
changeset
|
204 |
else if (lev == "level_logic") |
36472385a1cc
NS_LOG parsing changes to address bug 91
Craig Dowell <craigdo@ee.washington.edu>
parents:
1775
diff
changeset
|
205 |
{ |
36472385a1cc
NS_LOG parsing changes to address bug 91
Craig Dowell <craigdo@ee.washington.edu>
parents:
1775
diff
changeset
|
206 |
level |= LOG_LEVEL_LOGIC; |
36472385a1cc
NS_LOG parsing changes to address bug 91
Craig Dowell <craigdo@ee.washington.edu>
parents:
1775
diff
changeset
|
207 |
} |
36472385a1cc
NS_LOG parsing changes to address bug 91
Craig Dowell <craigdo@ee.washington.edu>
parents:
1775
diff
changeset
|
208 |
else if (lev == "level_all") |
36472385a1cc
NS_LOG parsing changes to address bug 91
Craig Dowell <craigdo@ee.washington.edu>
parents:
1775
diff
changeset
|
209 |
{ |
36472385a1cc
NS_LOG parsing changes to address bug 91
Craig Dowell <craigdo@ee.washington.edu>
parents:
1775
diff
changeset
|
210 |
level |= LOG_LEVEL_ALL; |
36472385a1cc
NS_LOG parsing changes to address bug 91
Craig Dowell <craigdo@ee.washington.edu>
parents:
1775
diff
changeset
|
211 |
} |
36472385a1cc
NS_LOG parsing changes to address bug 91
Craig Dowell <craigdo@ee.washington.edu>
parents:
1775
diff
changeset
|
212 |
} while (next_lev != std::string::npos); |
36472385a1cc
NS_LOG parsing changes to address bug 91
Craig Dowell <craigdo@ee.washington.edu>
parents:
1775
diff
changeset
|
213 |
|
36472385a1cc
NS_LOG parsing changes to address bug 91
Craig Dowell <craigdo@ee.washington.edu>
parents:
1775
diff
changeset
|
214 |
Enable ((enum LogLevel)level); |
1498
520bc8457799
log rides along for free
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
215 |
} |
520bc8457799
log rides along for free
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
216 |
} |
520bc8457799
log rides along for free
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
217 |
cur = next + 1; |
520bc8457799
log rides along for free
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
218 |
} |
520bc8457799
log rides along for free
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
219 |
#endif |
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 |
|
1503
53dd8f414ba6
sorting out logging
Craig Dowell <craigdo@ee.washington.edu>
parents:
1498
diff
changeset
|
222 |
|
1498
520bc8457799
log rides along for free
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
223 |
bool |
520bc8457799
log rides along for free
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
224 |
LogComponent::IsEnabled (enum LogLevel level) const |
520bc8457799
log rides along for free
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
225 |
{ |
1775
5abf6f0d1eca
deal with static constructor problem
Craig Dowell <craigdo@ee.washington.edu>
parents:
1773
diff
changeset
|
226 |
// LogComponentEnableEnvVar (); |
1507
11a370eecc52
allow discrete levels
Craig Dowell <craigdo@ee.washington.edu>
parents:
1506
diff
changeset
|
227 |
return (level & m_levels) ? 1 : 0; |
1498
520bc8457799
log rides along for free
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
228 |
} |
1503
53dd8f414ba6
sorting out logging
Craig Dowell <craigdo@ee.washington.edu>
parents:
1498
diff
changeset
|
229 |
|
1498
520bc8457799
log rides along for free
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
230 |
bool |
520bc8457799
log rides along for free
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
231 |
LogComponent::IsNoneEnabled (void) const |
520bc8457799
log rides along for free
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
232 |
{ |
520bc8457799
log rides along for free
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
233 |
return m_levels == 0; |
520bc8457799
log rides along for free
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
234 |
} |
1503
53dd8f414ba6
sorting out logging
Craig Dowell <craigdo@ee.washington.edu>
parents:
1498
diff
changeset
|
235 |
|
1498
520bc8457799
log rides along for free
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
236 |
void |
520bc8457799
log rides along for free
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
237 |
LogComponent::Enable (enum LogLevel level) |
520bc8457799
log rides along for free
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
238 |
{ |
520bc8457799
log rides along for free
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
239 |
m_levels |= level; |
520bc8457799
log rides along for free
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
240 |
} |
1503
53dd8f414ba6
sorting out logging
Craig Dowell <craigdo@ee.washington.edu>
parents:
1498
diff
changeset
|
241 |
|
1498
520bc8457799
log rides along for free
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
242 |
void |
520bc8457799
log rides along for free
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
243 |
LogComponent::Disable (enum LogLevel level) |
520bc8457799
log rides along for free
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
244 |
{ |
520bc8457799
log rides along for free
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
245 |
m_levels &= ~level; |
520bc8457799
log rides along for free
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
246 |
} |
520bc8457799
log rides along for free
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
247 |
|
1772
dd278e20e52e
log verbosity changes
Craig Dowell <craigdo@ee.washington.edu>
parents:
1507
diff
changeset
|
248 |
char const * |
dd278e20e52e
log verbosity changes
Craig Dowell <craigdo@ee.washington.edu>
parents:
1507
diff
changeset
|
249 |
LogComponent::Name (void) const |
dd278e20e52e
log verbosity changes
Craig Dowell <craigdo@ee.washington.edu>
parents:
1507
diff
changeset
|
250 |
{ |
dd278e20e52e
log verbosity changes
Craig Dowell <craigdo@ee.washington.edu>
parents:
1507
diff
changeset
|
251 |
return m_name; |
dd278e20e52e
log verbosity changes
Craig Dowell <craigdo@ee.washington.edu>
parents:
1507
diff
changeset
|
252 |
} |
dd278e20e52e
log verbosity changes
Craig Dowell <craigdo@ee.washington.edu>
parents:
1507
diff
changeset
|
253 |
|
dd278e20e52e
log verbosity changes
Craig Dowell <craigdo@ee.washington.edu>
parents:
1507
diff
changeset
|
254 |
|
1498
520bc8457799
log rides along for free
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
255 |
void |
520bc8457799
log rides along for free
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
256 |
LogComponentEnable (char const *name, enum LogLevel level) |
520bc8457799
log rides along for free
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
257 |
{ |
520bc8457799
log rides along for free
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
258 |
ComponentList *components = GetComponentList (); |
520bc8457799
log rides along for free
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
259 |
for (ComponentListI i = components->begin (); |
520bc8457799
log rides along for free
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
260 |
i != components->end (); |
520bc8457799
log rides along for free
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
261 |
i++) |
520bc8457799
log rides along for free
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
262 |
{ |
520bc8457799
log rides along for free
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
263 |
if (i->first.compare (name) == 0) |
7169
358f71a624d8
core coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents:
7017
diff
changeset
|
264 |
{ |
358f71a624d8
core coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents:
7017
diff
changeset
|
265 |
i->second->Enable (level); |
358f71a624d8
core coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents:
7017
diff
changeset
|
266 |
break; |
358f71a624d8
core coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents:
7017
diff
changeset
|
267 |
} |
358f71a624d8
core coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents:
7017
diff
changeset
|
268 |
} |
1498
520bc8457799
log rides along for free
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
269 |
} |
1503
53dd8f414ba6
sorting out logging
Craig Dowell <craigdo@ee.washington.edu>
parents:
1498
diff
changeset
|
270 |
|
1498
520bc8457799
log rides along for free
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
271 |
void |
1772
dd278e20e52e
log verbosity changes
Craig Dowell <craigdo@ee.washington.edu>
parents:
1507
diff
changeset
|
272 |
LogComponentEnableAll (enum LogLevel level) |
dd278e20e52e
log verbosity changes
Craig Dowell <craigdo@ee.washington.edu>
parents:
1507
diff
changeset
|
273 |
{ |
dd278e20e52e
log verbosity changes
Craig Dowell <craigdo@ee.washington.edu>
parents:
1507
diff
changeset
|
274 |
ComponentList *components = GetComponentList (); |
dd278e20e52e
log verbosity changes
Craig Dowell <craigdo@ee.washington.edu>
parents:
1507
diff
changeset
|
275 |
for (ComponentListI i = components->begin (); |
dd278e20e52e
log verbosity changes
Craig Dowell <craigdo@ee.washington.edu>
parents:
1507
diff
changeset
|
276 |
i != components->end (); |
dd278e20e52e
log verbosity changes
Craig Dowell <craigdo@ee.washington.edu>
parents:
1507
diff
changeset
|
277 |
i++) |
dd278e20e52e
log verbosity changes
Craig Dowell <craigdo@ee.washington.edu>
parents:
1507
diff
changeset
|
278 |
{ |
dd278e20e52e
log verbosity changes
Craig Dowell <craigdo@ee.washington.edu>
parents:
1507
diff
changeset
|
279 |
i->second->Enable (level); |
7169
358f71a624d8
core coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents:
7017
diff
changeset
|
280 |
} |
1772
dd278e20e52e
log verbosity changes
Craig Dowell <craigdo@ee.washington.edu>
parents:
1507
diff
changeset
|
281 |
} |
dd278e20e52e
log verbosity changes
Craig Dowell <craigdo@ee.washington.edu>
parents:
1507
diff
changeset
|
282 |
|
dd278e20e52e
log verbosity changes
Craig Dowell <craigdo@ee.washington.edu>
parents:
1507
diff
changeset
|
283 |
void |
1498
520bc8457799
log rides along for free
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
284 |
LogComponentDisable (char const *name, enum LogLevel level) |
520bc8457799
log rides along for free
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
285 |
{ |
520bc8457799
log rides along for free
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
286 |
ComponentList *components = GetComponentList (); |
520bc8457799
log rides along for free
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
287 |
for (ComponentListI i = components->begin (); |
520bc8457799
log rides along for free
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
288 |
i != components->end (); |
520bc8457799
log rides along for free
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
289 |
i++) |
520bc8457799
log rides along for free
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
290 |
{ |
520bc8457799
log rides along for free
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
291 |
if (i->first.compare (name) == 0) |
7169
358f71a624d8
core coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents:
7017
diff
changeset
|
292 |
{ |
358f71a624d8
core coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents:
7017
diff
changeset
|
293 |
i->second->Disable (level); |
358f71a624d8
core coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents:
7017
diff
changeset
|
294 |
break; |
358f71a624d8
core coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents:
7017
diff
changeset
|
295 |
} |
358f71a624d8
core coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents:
7017
diff
changeset
|
296 |
} |
1498
520bc8457799
log rides along for free
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
297 |
} |
520bc8457799
log rides along for free
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
298 |
|
520bc8457799
log rides along for free
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
299 |
void |
1772
dd278e20e52e
log verbosity changes
Craig Dowell <craigdo@ee.washington.edu>
parents:
1507
diff
changeset
|
300 |
LogComponentDisableAll (enum LogLevel level) |
dd278e20e52e
log verbosity changes
Craig Dowell <craigdo@ee.washington.edu>
parents:
1507
diff
changeset
|
301 |
{ |
dd278e20e52e
log verbosity changes
Craig Dowell <craigdo@ee.washington.edu>
parents:
1507
diff
changeset
|
302 |
ComponentList *components = GetComponentList (); |
dd278e20e52e
log verbosity changes
Craig Dowell <craigdo@ee.washington.edu>
parents:
1507
diff
changeset
|
303 |
for (ComponentListI i = components->begin (); |
dd278e20e52e
log verbosity changes
Craig Dowell <craigdo@ee.washington.edu>
parents:
1507
diff
changeset
|
304 |
i != components->end (); |
dd278e20e52e
log verbosity changes
Craig Dowell <craigdo@ee.washington.edu>
parents:
1507
diff
changeset
|
305 |
i++) |
dd278e20e52e
log verbosity changes
Craig Dowell <craigdo@ee.washington.edu>
parents:
1507
diff
changeset
|
306 |
{ |
dd278e20e52e
log verbosity changes
Craig Dowell <craigdo@ee.washington.edu>
parents:
1507
diff
changeset
|
307 |
i->second->Disable (level); |
7169
358f71a624d8
core coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents:
7017
diff
changeset
|
308 |
} |
1772
dd278e20e52e
log verbosity changes
Craig Dowell <craigdo@ee.washington.edu>
parents:
1507
diff
changeset
|
309 |
} |
dd278e20e52e
log verbosity changes
Craig Dowell <craigdo@ee.washington.edu>
parents:
1507
diff
changeset
|
310 |
|
dd278e20e52e
log verbosity changes
Craig Dowell <craigdo@ee.washington.edu>
parents:
1507
diff
changeset
|
311 |
void |
1498
520bc8457799
log rides along for free
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
312 |
LogComponentPrintList (void) |
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 |
ComponentList *components = GetComponentList (); |
520bc8457799
log rides along for free
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
315 |
for (ComponentListI i = components->begin (); |
520bc8457799
log rides along for free
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
316 |
i != components->end (); |
520bc8457799
log rides along for free
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
317 |
i++) |
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 |
std::cout << i->first << "="; |
520bc8457799
log rides along for free
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
320 |
if (i->second->IsNoneEnabled ()) |
520bc8457799
log rides along for free
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
321 |
{ |
520bc8457799
log rides along for free
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
322 |
std::cout << "0" << std::endl; |
520bc8457799
log rides along for free
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
323 |
continue; |
520bc8457799
log rides along for free
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
324 |
} |
1507
11a370eecc52
allow discrete levels
Craig Dowell <craigdo@ee.washington.edu>
parents:
1506
diff
changeset
|
325 |
if (i->second->IsEnabled (LOG_ERROR)) |
1503
53dd8f414ba6
sorting out logging
Craig Dowell <craigdo@ee.washington.edu>
parents:
1498
diff
changeset
|
326 |
{ |
53dd8f414ba6
sorting out logging
Craig Dowell <craigdo@ee.washington.edu>
parents:
1498
diff
changeset
|
327 |
std::cout << "error"; |
53dd8f414ba6
sorting out logging
Craig Dowell <craigdo@ee.washington.edu>
parents:
1498
diff
changeset
|
328 |
} |
1507
11a370eecc52
allow discrete levels
Craig Dowell <craigdo@ee.washington.edu>
parents:
1506
diff
changeset
|
329 |
if (i->second->IsEnabled (LOG_WARN)) |
1503
53dd8f414ba6
sorting out logging
Craig Dowell <craigdo@ee.washington.edu>
parents:
1498
diff
changeset
|
330 |
{ |
53dd8f414ba6
sorting out logging
Craig Dowell <craigdo@ee.washington.edu>
parents:
1498
diff
changeset
|
331 |
std::cout << "|warn"; |
53dd8f414ba6
sorting out logging
Craig Dowell <craigdo@ee.washington.edu>
parents:
1498
diff
changeset
|
332 |
} |
1507
11a370eecc52
allow discrete levels
Craig Dowell <craigdo@ee.washington.edu>
parents:
1506
diff
changeset
|
333 |
if (i->second->IsEnabled (LOG_DEBUG)) |
1498
520bc8457799
log rides along for free
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
334 |
{ |
1503
53dd8f414ba6
sorting out logging
Craig Dowell <craigdo@ee.washington.edu>
parents:
1498
diff
changeset
|
335 |
std::cout << "|debug"; |
53dd8f414ba6
sorting out logging
Craig Dowell <craigdo@ee.washington.edu>
parents:
1498
diff
changeset
|
336 |
} |
1507
11a370eecc52
allow discrete levels
Craig Dowell <craigdo@ee.washington.edu>
parents:
1506
diff
changeset
|
337 |
if (i->second->IsEnabled (LOG_INFO)) |
1503
53dd8f414ba6
sorting out logging
Craig Dowell <craigdo@ee.washington.edu>
parents:
1498
diff
changeset
|
338 |
{ |
53dd8f414ba6
sorting out logging
Craig Dowell <craigdo@ee.washington.edu>
parents:
1498
diff
changeset
|
339 |
std::cout << "|info"; |
1498
520bc8457799
log rides along for free
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
340 |
} |
1507
11a370eecc52
allow discrete levels
Craig Dowell <craigdo@ee.washington.edu>
parents:
1506
diff
changeset
|
341 |
if (i->second->IsEnabled (LOG_FUNCTION)) |
1498
520bc8457799
log rides along for free
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
342 |
{ |
1503
53dd8f414ba6
sorting out logging
Craig Dowell <craigdo@ee.washington.edu>
parents:
1498
diff
changeset
|
343 |
std::cout << "|function"; |
1498
520bc8457799
log rides along for free
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
344 |
} |
1507
11a370eecc52
allow discrete levels
Craig Dowell <craigdo@ee.washington.edu>
parents:
1506
diff
changeset
|
345 |
if (i->second->IsEnabled (LOG_LOGIC)) |
1498
520bc8457799
log rides along for free
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
346 |
{ |
1503
53dd8f414ba6
sorting out logging
Craig Dowell <craigdo@ee.washington.edu>
parents:
1498
diff
changeset
|
347 |
std::cout << "|logic"; |
1498
520bc8457799
log rides along for free
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
348 |
} |
1507
11a370eecc52
allow discrete levels
Craig Dowell <craigdo@ee.washington.edu>
parents:
1506
diff
changeset
|
349 |
if (i->second->IsEnabled (LOG_ALL)) |
1498
520bc8457799
log rides along for free
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
350 |
{ |
1503
53dd8f414ba6
sorting out logging
Craig Dowell <craigdo@ee.washington.edu>
parents:
1498
diff
changeset
|
351 |
std::cout << "|all"; |
1498
520bc8457799
log rides along for free
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
352 |
} |
520bc8457799
log rides along for free
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
353 |
std::cout << std::endl; |
520bc8457799
log rides along for free
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
354 |
} |
520bc8457799
log rides along for free
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
355 |
} |
520bc8457799
log rides along for free
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
356 |
|
3005
cc521f35f033
avoid segfault when setting NS_LOG=*
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2983
diff
changeset
|
357 |
void LogSetTimePrinter (LogTimePrinter printer) |
2979
3d39dd617b8d
add time logging support
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2976
diff
changeset
|
358 |
{ |
3d39dd617b8d
add time logging support
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2976
diff
changeset
|
359 |
g_logTimePrinter = printer; |
3d39dd617b8d
add time logging support
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2976
diff
changeset
|
360 |
} |
3d39dd617b8d
add time logging support
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2976
diff
changeset
|
361 |
LogTimePrinter LogGetTimePrinter(void) |
3d39dd617b8d
add time logging support
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2976
diff
changeset
|
362 |
{ |
3d39dd617b8d
add time logging support
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2976
diff
changeset
|
363 |
return g_logTimePrinter; |
3d39dd617b8d
add time logging support
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2976
diff
changeset
|
364 |
} |
3d39dd617b8d
add time logging support
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2976
diff
changeset
|
365 |
|
5522
0d1a06c5b285
Print node context in log messages
Guillaume Seguin <guillaume@segu.in>
parents:
3483
diff
changeset
|
366 |
void LogSetNodePrinter (LogNodePrinter printer) |
0d1a06c5b285
Print node context in log messages
Guillaume Seguin <guillaume@segu.in>
parents:
3483
diff
changeset
|
367 |
{ |
0d1a06c5b285
Print node context in log messages
Guillaume Seguin <guillaume@segu.in>
parents:
3483
diff
changeset
|
368 |
g_logNodePrinter = printer; |
0d1a06c5b285
Print node context in log messages
Guillaume Seguin <guillaume@segu.in>
parents:
3483
diff
changeset
|
369 |
} |
0d1a06c5b285
Print node context in log messages
Guillaume Seguin <guillaume@segu.in>
parents:
3483
diff
changeset
|
370 |
LogNodePrinter LogGetNodePrinter(void) |
0d1a06c5b285
Print node context in log messages
Guillaume Seguin <guillaume@segu.in>
parents:
3483
diff
changeset
|
371 |
{ |
0d1a06c5b285
Print node context in log messages
Guillaume Seguin <guillaume@segu.in>
parents:
3483
diff
changeset
|
372 |
return g_logNodePrinter; |
0d1a06c5b285
Print node context in log messages
Guillaume Seguin <guillaume@segu.in>
parents:
3483
diff
changeset
|
373 |
} |
0d1a06c5b285
Print node context in log messages
Guillaume Seguin <guillaume@segu.in>
parents:
3483
diff
changeset
|
374 |
|
2979
3d39dd617b8d
add time logging support
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2976
diff
changeset
|
375 |
|
3d39dd617b8d
add time logging support
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2976
diff
changeset
|
376 |
ParameterLogger::ParameterLogger (std::ostream &os) |
3d39dd617b8d
add time logging support
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2976
diff
changeset
|
377 |
: m_itemNumber (0), |
3d39dd617b8d
add time logging support
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2976
diff
changeset
|
378 |
m_os (os) |
7169
358f71a624d8
core coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents:
7017
diff
changeset
|
379 |
{ |
358f71a624d8
core coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents:
7017
diff
changeset
|
380 |
} |
1828
6ab68edddf45
nicer logging of parameters (bug 79 patch from Gustavo)
Tom Henderson <tomh@tomh.org>
parents:
1783
diff
changeset
|
381 |
|
1498
520bc8457799
log rides along for free
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
382 |
} // namespace ns3 |