author | Mathieu Lacage <mathieu.lacage@sophia.inria.fr> |
Sun, 02 Mar 2008 21:00:37 +0100 | |
changeset 2531 | b451b5fc8b57 |
parent 1862 | 3627401f90cf |
child 2809 | 30e451c21f60 |
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:
1503
diff
changeset
|
20 |
|
1783
36472385a1cc
NS_LOG parsing changes to address bug 91
Craig Dowell <craigdo@ee.washington.edu>
parents:
1775
diff
changeset
|
21 |
// What about print-list!!!!!!??????? |
36472385a1cc
NS_LOG parsing changes to address bug 91
Craig Dowell <craigdo@ee.washington.edu>
parents:
1775
diff
changeset
|
22 |
|
1506
3c8b23550e6a
disable log unless debug build
Craig Dowell <craigdo@ee.washington.edu>
parents:
1503
diff
changeset
|
23 |
#ifdef NS3_LOG_ENABLE |
3c8b23550e6a
disable log unless debug build
Craig Dowell <craigdo@ee.washington.edu>
parents:
1503
diff
changeset
|
24 |
|
1498
520bc8457799
log rides along for free
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
25 |
#include <list> |
520bc8457799
log rides along for free
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
26 |
#include <utility> |
520bc8457799
log rides along for free
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
27 |
#include <iostream> |
520bc8457799
log rides along for free
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
28 |
#include "log.h" |
520bc8457799
log rides along for free
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
29 |
#include "assert.h" |
520bc8457799
log rides along for free
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
30 |
#include "ns3/core-config.h" |
520bc8457799
log rides along for free
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
31 |
#include "fatal-error.h" |
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 |
#ifdef HAVE_STDLIB_H |
520bc8457799
log rides along for free
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
34 |
#include <stdlib.h> |
520bc8457799
log rides along for free
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
35 |
#endif |
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 |
namespace ns3 { |
520bc8457799
log rides along for free
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
38 |
|
520bc8457799
log rides along for free
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
39 |
typedef std::list<std::pair <std::string, LogComponent *> > ComponentList; |
520bc8457799
log rides along for free
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
40 |
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
|
41 |
|
1861
5bc0b0d8d620
bug 91: add print-list support to NS_LOG env var.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1828
diff
changeset
|
42 |
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
|
43 |
{ |
5bc0b0d8d620
bug 91: add print-list support to NS_LOG env var.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1828
diff
changeset
|
44 |
public: |
5bc0b0d8d620
bug 91: add print-list support to NS_LOG env var.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1828
diff
changeset
|
45 |
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 |
} 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
|
47 |
|
1498
520bc8457799
log rides along for free
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
48 |
static |
520bc8457799
log rides along for free
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
49 |
ComponentList *GetComponentList (void) |
520bc8457799
log rides along for free
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
50 |
{ |
520bc8457799
log rides along for free
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
51 |
static ComponentList components; |
520bc8457799
log rides along for free
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
52 |
return &components; |
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 |
|
1861
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 |
|
5bc0b0d8d620
bug 91: add print-list support to NS_LOG env var.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1828
diff
changeset
|
57 |
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
|
58 |
{ |
5bc0b0d8d620
bug 91: add print-list support to NS_LOG env var.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1828
diff
changeset
|
59 |
#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
|
60 |
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
|
61 |
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
|
62 |
{ |
5bc0b0d8d620
bug 91: add print-list support to NS_LOG env var.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1828
diff
changeset
|
63 |
return; |
5bc0b0d8d620
bug 91: add print-list support to NS_LOG env var.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1828
diff
changeset
|
64 |
} |
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 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
|
66 |
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
|
67 |
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
|
68 |
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
|
69 |
{ |
5bc0b0d8d620
bug 91: add print-list support to NS_LOG env var.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1828
diff
changeset
|
70 |
next = env.find_first_of (";", 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 |
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
|
72 |
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
|
73 |
{ |
5bc0b0d8d620
bug 91: add print-list support to NS_LOG env var.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1828
diff
changeset
|
74 |
LogComponentPrintList (); |
5bc0b0d8d620
bug 91: add print-list support to NS_LOG env var.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1828
diff
changeset
|
75 |
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
|
76 |
break; |
5bc0b0d8d620
bug 91: add print-list support to NS_LOG env var.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1828
diff
changeset
|
77 |
} |
5bc0b0d8d620
bug 91: add print-list support to NS_LOG env var.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1828
diff
changeset
|
78 |
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
|
79 |
} |
5bc0b0d8d620
bug 91: add print-list support to NS_LOG env var.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1828
diff
changeset
|
80 |
#endif |
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 |
|
5bc0b0d8d620
bug 91: add print-list support to NS_LOG env var.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1828
diff
changeset
|
83 |
|
1783
36472385a1cc
NS_LOG parsing changes to address bug 91
Craig Dowell <craigdo@ee.washington.edu>
parents:
1775
diff
changeset
|
84 |
LogComponent::LogComponent (char const * name) |
36472385a1cc
NS_LOG parsing changes to address bug 91
Craig Dowell <craigdo@ee.washington.edu>
parents:
1775
diff
changeset
|
85 |
: m_levels (0), m_name (name) |
1498
520bc8457799
log rides along for free
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
86 |
{ |
1783
36472385a1cc
NS_LOG parsing changes to address bug 91
Craig Dowell <craigdo@ee.washington.edu>
parents:
1775
diff
changeset
|
87 |
EnvVarCheck (name); |
36472385a1cc
NS_LOG parsing changes to address bug 91
Craig Dowell <craigdo@ee.washington.edu>
parents:
1775
diff
changeset
|
88 |
|
36472385a1cc
NS_LOG parsing changes to address bug 91
Craig Dowell <craigdo@ee.washington.edu>
parents:
1775
diff
changeset
|
89 |
ComponentList *components = GetComponentList (); |
36472385a1cc
NS_LOG parsing changes to address bug 91
Craig Dowell <craigdo@ee.washington.edu>
parents:
1775
diff
changeset
|
90 |
for (ComponentListI i = components->begin (); |
36472385a1cc
NS_LOG parsing changes to address bug 91
Craig Dowell <craigdo@ee.washington.edu>
parents:
1775
diff
changeset
|
91 |
i != components->end (); |
36472385a1cc
NS_LOG parsing changes to address bug 91
Craig Dowell <craigdo@ee.washington.edu>
parents:
1775
diff
changeset
|
92 |
i++) |
1498
520bc8457799
log rides along for free
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
93 |
{ |
1783
36472385a1cc
NS_LOG parsing changes to address bug 91
Craig Dowell <craigdo@ee.washington.edu>
parents:
1775
diff
changeset
|
94 |
NS_ASSERT (i->first != name); |
1498
520bc8457799
log rides along for free
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
95 |
} |
1783
36472385a1cc
NS_LOG parsing changes to address bug 91
Craig Dowell <craigdo@ee.washington.edu>
parents:
1775
diff
changeset
|
96 |
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
|
97 |
} |
1775
5abf6f0d1eca
deal with static constructor problem
Craig Dowell <craigdo@ee.washington.edu>
parents:
1773
diff
changeset
|
98 |
|
1783
36472385a1cc
NS_LOG parsing changes to address bug 91
Craig Dowell <craigdo@ee.washington.edu>
parents:
1775
diff
changeset
|
99 |
void |
36472385a1cc
NS_LOG parsing changes to address bug 91
Craig Dowell <craigdo@ee.washington.edu>
parents:
1775
diff
changeset
|
100 |
LogComponent::EnvVarCheck (char const * name) |
36472385a1cc
NS_LOG parsing changes to address bug 91
Craig Dowell <craigdo@ee.washington.edu>
parents:
1775
diff
changeset
|
101 |
{ |
1498
520bc8457799
log rides along for free
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
102 |
#ifdef HAVE_GETENV |
520bc8457799
log rides along for free
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
103 |
char *envVar = getenv("NS_LOG"); |
520bc8457799
log rides along for free
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
104 |
if (envVar == 0) |
520bc8457799
log rides along for free
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
105 |
{ |
520bc8457799
log rides along for free
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
106 |
return; |
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 |
std::string env = envVar; |
1783
36472385a1cc
NS_LOG parsing changes to address bug 91
Craig Dowell <craigdo@ee.washington.edu>
parents:
1775
diff
changeset
|
109 |
std::string myName = name; |
36472385a1cc
NS_LOG parsing changes to address bug 91
Craig Dowell <craigdo@ee.washington.edu>
parents:
1775
diff
changeset
|
110 |
|
1498
520bc8457799
log rides along for free
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
111 |
std::string::size_type cur = 0; |
520bc8457799
log rides along for free
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
112 |
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
|
113 |
while (next != std::string::npos) |
1498
520bc8457799
log rides along for free
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
114 |
{ |
520bc8457799
log rides along for free
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
115 |
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
|
116 |
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
|
117 |
std::string::size_type equal = tmp.find ("="); |
520bc8457799
log rides along for free
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
118 |
std::string component; |
520bc8457799
log rides along for free
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
119 |
if (equal == std::string::npos) |
520bc8457799
log rides along for free
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
120 |
{ |
520bc8457799
log rides along for free
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
121 |
component = tmp; |
1783
36472385a1cc
NS_LOG parsing changes to address bug 91
Craig Dowell <craigdo@ee.washington.edu>
parents:
1775
diff
changeset
|
122 |
if (component == myName || component == "*") |
36472385a1cc
NS_LOG parsing changes to address bug 91
Craig Dowell <craigdo@ee.washington.edu>
parents:
1775
diff
changeset
|
123 |
{ |
36472385a1cc
NS_LOG parsing changes to address bug 91
Craig Dowell <craigdo@ee.washington.edu>
parents:
1775
diff
changeset
|
124 |
Enable (LOG_DEBUG); |
36472385a1cc
NS_LOG parsing changes to address bug 91
Craig Dowell <craigdo@ee.washington.edu>
parents:
1775
diff
changeset
|
125 |
return; |
36472385a1cc
NS_LOG parsing changes to address bug 91
Craig Dowell <craigdo@ee.washington.edu>
parents:
1775
diff
changeset
|
126 |
} |
1498
520bc8457799
log rides along for free
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
127 |
} |
520bc8457799
log rides along for free
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
128 |
else |
520bc8457799
log rides along for free
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
129 |
{ |
520bc8457799
log rides along for free
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
130 |
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
|
131 |
if (component == myName || component == "*") |
1498
520bc8457799
log rides along for free
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
132 |
{ |
1783
36472385a1cc
NS_LOG parsing changes to address bug 91
Craig Dowell <craigdo@ee.washington.edu>
parents:
1775
diff
changeset
|
133 |
int level = 0; |
36472385a1cc
NS_LOG parsing changes to address bug 91
Craig Dowell <craigdo@ee.washington.edu>
parents:
1775
diff
changeset
|
134 |
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
|
135 |
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
|
136 |
do |
1503
53dd8f414ba6
sorting out logging
Craig Dowell <craigdo@ee.washington.edu>
parents:
1498
diff
changeset
|
137 |
{ |
1783
36472385a1cc
NS_LOG parsing changes to address bug 91
Craig Dowell <craigdo@ee.washington.edu>
parents:
1775
diff
changeset
|
138 |
cur_lev = next_lev + 1; |
36472385a1cc
NS_LOG parsing changes to address bug 91
Craig Dowell <craigdo@ee.washington.edu>
parents:
1775
diff
changeset
|
139 |
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
|
140 |
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
|
141 |
if (lev == "error") |
36472385a1cc
NS_LOG parsing changes to address bug 91
Craig Dowell <craigdo@ee.washington.edu>
parents:
1775
diff
changeset
|
142 |
{ |
36472385a1cc
NS_LOG parsing changes to address bug 91
Craig Dowell <craigdo@ee.washington.edu>
parents:
1775
diff
changeset
|
143 |
level |= LOG_ERROR; |
36472385a1cc
NS_LOG parsing changes to address bug 91
Craig Dowell <craigdo@ee.washington.edu>
parents:
1775
diff
changeset
|
144 |
} |
36472385a1cc
NS_LOG parsing changes to address bug 91
Craig Dowell <craigdo@ee.washington.edu>
parents:
1775
diff
changeset
|
145 |
else if (lev == "warn") |
36472385a1cc
NS_LOG parsing changes to address bug 91
Craig Dowell <craigdo@ee.washington.edu>
parents:
1775
diff
changeset
|
146 |
{ |
36472385a1cc
NS_LOG parsing changes to address bug 91
Craig Dowell <craigdo@ee.washington.edu>
parents:
1775
diff
changeset
|
147 |
level |= LOG_WARN; |
36472385a1cc
NS_LOG parsing changes to address bug 91
Craig Dowell <craigdo@ee.washington.edu>
parents:
1775
diff
changeset
|
148 |
} |
36472385a1cc
NS_LOG parsing changes to address bug 91
Craig Dowell <craigdo@ee.washington.edu>
parents:
1775
diff
changeset
|
149 |
else if (lev == "debug") |
36472385a1cc
NS_LOG parsing changes to address bug 91
Craig Dowell <craigdo@ee.washington.edu>
parents:
1775
diff
changeset
|
150 |
{ |
36472385a1cc
NS_LOG parsing changes to address bug 91
Craig Dowell <craigdo@ee.washington.edu>
parents:
1775
diff
changeset
|
151 |
level |= LOG_DEBUG; |
36472385a1cc
NS_LOG parsing changes to address bug 91
Craig Dowell <craigdo@ee.washington.edu>
parents:
1775
diff
changeset
|
152 |
} |
36472385a1cc
NS_LOG parsing changes to address bug 91
Craig Dowell <craigdo@ee.washington.edu>
parents:
1775
diff
changeset
|
153 |
else if (lev == "info") |
36472385a1cc
NS_LOG parsing changes to address bug 91
Craig Dowell <craigdo@ee.washington.edu>
parents:
1775
diff
changeset
|
154 |
{ |
36472385a1cc
NS_LOG parsing changes to address bug 91
Craig Dowell <craigdo@ee.washington.edu>
parents:
1775
diff
changeset
|
155 |
level |= LOG_INFO; |
36472385a1cc
NS_LOG parsing changes to address bug 91
Craig Dowell <craigdo@ee.washington.edu>
parents:
1775
diff
changeset
|
156 |
} |
36472385a1cc
NS_LOG parsing changes to address bug 91
Craig Dowell <craigdo@ee.washington.edu>
parents:
1775
diff
changeset
|
157 |
else if (lev == "function") |
36472385a1cc
NS_LOG parsing changes to address bug 91
Craig Dowell <craigdo@ee.washington.edu>
parents:
1775
diff
changeset
|
158 |
{ |
36472385a1cc
NS_LOG parsing changes to address bug 91
Craig Dowell <craigdo@ee.washington.edu>
parents:
1775
diff
changeset
|
159 |
level |= LOG_FUNCTION; |
36472385a1cc
NS_LOG parsing changes to address bug 91
Craig Dowell <craigdo@ee.washington.edu>
parents:
1775
diff
changeset
|
160 |
} |
36472385a1cc
NS_LOG parsing changes to address bug 91
Craig Dowell <craigdo@ee.washington.edu>
parents:
1775
diff
changeset
|
161 |
else if (lev == "param") |
36472385a1cc
NS_LOG parsing changes to address bug 91
Craig Dowell <craigdo@ee.washington.edu>
parents:
1775
diff
changeset
|
162 |
{ |
36472385a1cc
NS_LOG parsing changes to address bug 91
Craig Dowell <craigdo@ee.washington.edu>
parents:
1775
diff
changeset
|
163 |
level |= LOG_PARAM; |
36472385a1cc
NS_LOG parsing changes to address bug 91
Craig Dowell <craigdo@ee.washington.edu>
parents:
1775
diff
changeset
|
164 |
} |
36472385a1cc
NS_LOG parsing changes to address bug 91
Craig Dowell <craigdo@ee.washington.edu>
parents:
1775
diff
changeset
|
165 |
else if (lev == "logic") |
36472385a1cc
NS_LOG parsing changes to address bug 91
Craig Dowell <craigdo@ee.washington.edu>
parents:
1775
diff
changeset
|
166 |
{ |
36472385a1cc
NS_LOG parsing changes to address bug 91
Craig Dowell <craigdo@ee.washington.edu>
parents:
1775
diff
changeset
|
167 |
level |= LOG_LOGIC; |
36472385a1cc
NS_LOG parsing changes to address bug 91
Craig Dowell <craigdo@ee.washington.edu>
parents:
1775
diff
changeset
|
168 |
} |
36472385a1cc
NS_LOG parsing changes to address bug 91
Craig Dowell <craigdo@ee.washington.edu>
parents:
1775
diff
changeset
|
169 |
else if (lev == "all") |
36472385a1cc
NS_LOG parsing changes to address bug 91
Craig Dowell <craigdo@ee.washington.edu>
parents:
1775
diff
changeset
|
170 |
{ |
36472385a1cc
NS_LOG parsing changes to address bug 91
Craig Dowell <craigdo@ee.washington.edu>
parents:
1775
diff
changeset
|
171 |
level |= LOG_ALL; |
36472385a1cc
NS_LOG parsing changes to address bug 91
Craig Dowell <craigdo@ee.washington.edu>
parents:
1775
diff
changeset
|
172 |
} |
36472385a1cc
NS_LOG parsing changes to address bug 91
Craig Dowell <craigdo@ee.washington.edu>
parents:
1775
diff
changeset
|
173 |
else if (lev == "prefix") |
36472385a1cc
NS_LOG parsing changes to address bug 91
Craig Dowell <craigdo@ee.washington.edu>
parents:
1775
diff
changeset
|
174 |
{ |
36472385a1cc
NS_LOG parsing changes to address bug 91
Craig Dowell <craigdo@ee.washington.edu>
parents:
1775
diff
changeset
|
175 |
level |= LOG_PREFIX_ALL; |
36472385a1cc
NS_LOG parsing changes to address bug 91
Craig Dowell <craigdo@ee.washington.edu>
parents:
1775
diff
changeset
|
176 |
} |
36472385a1cc
NS_LOG parsing changes to address bug 91
Craig Dowell <craigdo@ee.washington.edu>
parents:
1775
diff
changeset
|
177 |
else if (lev == "level_error") |
36472385a1cc
NS_LOG parsing changes to address bug 91
Craig Dowell <craigdo@ee.washington.edu>
parents:
1775
diff
changeset
|
178 |
{ |
36472385a1cc
NS_LOG parsing changes to address bug 91
Craig Dowell <craigdo@ee.washington.edu>
parents:
1775
diff
changeset
|
179 |
level |= LOG_LEVEL_ERROR; |
36472385a1cc
NS_LOG parsing changes to address bug 91
Craig Dowell <craigdo@ee.washington.edu>
parents:
1775
diff
changeset
|
180 |
} |
36472385a1cc
NS_LOG parsing changes to address bug 91
Craig Dowell <craigdo@ee.washington.edu>
parents:
1775
diff
changeset
|
181 |
else if (lev == "level_warn") |
36472385a1cc
NS_LOG parsing changes to address bug 91
Craig Dowell <craigdo@ee.washington.edu>
parents:
1775
diff
changeset
|
182 |
{ |
36472385a1cc
NS_LOG parsing changes to address bug 91
Craig Dowell <craigdo@ee.washington.edu>
parents:
1775
diff
changeset
|
183 |
level |= LOG_LEVEL_WARN; |
36472385a1cc
NS_LOG parsing changes to address bug 91
Craig Dowell <craigdo@ee.washington.edu>
parents:
1775
diff
changeset
|
184 |
} |
36472385a1cc
NS_LOG parsing changes to address bug 91
Craig Dowell <craigdo@ee.washington.edu>
parents:
1775
diff
changeset
|
185 |
else if (lev == "level_debug") |
36472385a1cc
NS_LOG parsing changes to address bug 91
Craig Dowell <craigdo@ee.washington.edu>
parents:
1775
diff
changeset
|
186 |
{ |
36472385a1cc
NS_LOG parsing changes to address bug 91
Craig Dowell <craigdo@ee.washington.edu>
parents:
1775
diff
changeset
|
187 |
level |= LOG_LEVEL_DEBUG; |
36472385a1cc
NS_LOG parsing changes to address bug 91
Craig Dowell <craigdo@ee.washington.edu>
parents:
1775
diff
changeset
|
188 |
} |
36472385a1cc
NS_LOG parsing changes to address bug 91
Craig Dowell <craigdo@ee.washington.edu>
parents:
1775
diff
changeset
|
189 |
else if (lev == "level_info") |
36472385a1cc
NS_LOG parsing changes to address bug 91
Craig Dowell <craigdo@ee.washington.edu>
parents:
1775
diff
changeset
|
190 |
{ |
36472385a1cc
NS_LOG parsing changes to address bug 91
Craig Dowell <craigdo@ee.washington.edu>
parents:
1775
diff
changeset
|
191 |
level |= LOG_LEVEL_INFO; |
36472385a1cc
NS_LOG parsing changes to address bug 91
Craig Dowell <craigdo@ee.washington.edu>
parents:
1775
diff
changeset
|
192 |
} |
36472385a1cc
NS_LOG parsing changes to address bug 91
Craig Dowell <craigdo@ee.washington.edu>
parents:
1775
diff
changeset
|
193 |
else if (lev == "level_function") |
36472385a1cc
NS_LOG parsing changes to address bug 91
Craig Dowell <craigdo@ee.washington.edu>
parents:
1775
diff
changeset
|
194 |
{ |
36472385a1cc
NS_LOG parsing changes to address bug 91
Craig Dowell <craigdo@ee.washington.edu>
parents:
1775
diff
changeset
|
195 |
level |= LOG_LEVEL_FUNCTION; |
36472385a1cc
NS_LOG parsing changes to address bug 91
Craig Dowell <craigdo@ee.washington.edu>
parents:
1775
diff
changeset
|
196 |
} |
36472385a1cc
NS_LOG parsing changes to address bug 91
Craig Dowell <craigdo@ee.washington.edu>
parents:
1775
diff
changeset
|
197 |
else if (lev == "level_param") |
36472385a1cc
NS_LOG parsing changes to address bug 91
Craig Dowell <craigdo@ee.washington.edu>
parents:
1775
diff
changeset
|
198 |
{ |
36472385a1cc
NS_LOG parsing changes to address bug 91
Craig Dowell <craigdo@ee.washington.edu>
parents:
1775
diff
changeset
|
199 |
level |= LOG_LEVEL_PARAM; |
36472385a1cc
NS_LOG parsing changes to address bug 91
Craig Dowell <craigdo@ee.washington.edu>
parents:
1775
diff
changeset
|
200 |
} |
36472385a1cc
NS_LOG parsing changes to address bug 91
Craig Dowell <craigdo@ee.washington.edu>
parents:
1775
diff
changeset
|
201 |
else if (lev == "level_logic") |
36472385a1cc
NS_LOG parsing changes to address bug 91
Craig Dowell <craigdo@ee.washington.edu>
parents:
1775
diff
changeset
|
202 |
{ |
36472385a1cc
NS_LOG parsing changes to address bug 91
Craig Dowell <craigdo@ee.washington.edu>
parents:
1775
diff
changeset
|
203 |
level |= LOG_LEVEL_LOGIC; |
36472385a1cc
NS_LOG parsing changes to address bug 91
Craig Dowell <craigdo@ee.washington.edu>
parents:
1775
diff
changeset
|
204 |
} |
36472385a1cc
NS_LOG parsing changes to address bug 91
Craig Dowell <craigdo@ee.washington.edu>
parents:
1775
diff
changeset
|
205 |
else if (lev == "level_all") |
36472385a1cc
NS_LOG parsing changes to address bug 91
Craig Dowell <craigdo@ee.washington.edu>
parents:
1775
diff
changeset
|
206 |
{ |
36472385a1cc
NS_LOG parsing changes to address bug 91
Craig Dowell <craigdo@ee.washington.edu>
parents:
1775
diff
changeset
|
207 |
level |= LOG_LEVEL_ALL; |
36472385a1cc
NS_LOG parsing changes to address bug 91
Craig Dowell <craigdo@ee.washington.edu>
parents:
1775
diff
changeset
|
208 |
} |
36472385a1cc
NS_LOG parsing changes to address bug 91
Craig Dowell <craigdo@ee.washington.edu>
parents:
1775
diff
changeset
|
209 |
} 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
|
210 |
|
36472385a1cc
NS_LOG parsing changes to address bug 91
Craig Dowell <craigdo@ee.washington.edu>
parents:
1775
diff
changeset
|
211 |
Enable ((enum LogLevel)level); |
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 |
} |
520bc8457799
log rides along for free
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
214 |
cur = next + 1; |
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 |
#endif |
520bc8457799
log rides along for free
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
217 |
} |
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 |
|
1498
520bc8457799
log rides along for free
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
220 |
bool |
520bc8457799
log rides along for free
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
221 |
LogComponent::IsEnabled (enum LogLevel level) const |
520bc8457799
log rides along for free
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
222 |
{ |
1775
5abf6f0d1eca
deal with static constructor problem
Craig Dowell <craigdo@ee.washington.edu>
parents:
1773
diff
changeset
|
223 |
// LogComponentEnableEnvVar (); |
1507
11a370eecc52
allow discrete levels
Craig Dowell <craigdo@ee.washington.edu>
parents:
1506
diff
changeset
|
224 |
return (level & m_levels) ? 1 : 0; |
1498
520bc8457799
log rides along for free
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
225 |
} |
1503
53dd8f414ba6
sorting out logging
Craig Dowell <craigdo@ee.washington.edu>
parents:
1498
diff
changeset
|
226 |
|
1498
520bc8457799
log rides along for free
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
227 |
bool |
520bc8457799
log rides along for free
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
228 |
LogComponent::IsNoneEnabled (void) const |
520bc8457799
log rides along for free
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
229 |
{ |
520bc8457799
log rides along for free
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
230 |
return m_levels == 0; |
520bc8457799
log rides along for free
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
231 |
} |
1503
53dd8f414ba6
sorting out logging
Craig Dowell <craigdo@ee.washington.edu>
parents:
1498
diff
changeset
|
232 |
|
1498
520bc8457799
log rides along for free
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
233 |
void |
520bc8457799
log rides along for free
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
234 |
LogComponent::Enable (enum LogLevel level) |
520bc8457799
log rides along for free
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
235 |
{ |
520bc8457799
log rides along for free
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
236 |
m_levels |= level; |
520bc8457799
log rides along for free
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
237 |
} |
1503
53dd8f414ba6
sorting out logging
Craig Dowell <craigdo@ee.washington.edu>
parents:
1498
diff
changeset
|
238 |
|
1498
520bc8457799
log rides along for free
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
239 |
void |
520bc8457799
log rides along for free
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
240 |
LogComponent::Disable (enum LogLevel level) |
520bc8457799
log rides along for free
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
241 |
{ |
520bc8457799
log rides along for free
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
242 |
m_levels &= ~level; |
520bc8457799
log rides along for free
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
243 |
} |
520bc8457799
log rides along for free
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
244 |
|
1772
dd278e20e52e
log verbosity changes
Craig Dowell <craigdo@ee.washington.edu>
parents:
1507
diff
changeset
|
245 |
char const * |
dd278e20e52e
log verbosity changes
Craig Dowell <craigdo@ee.washington.edu>
parents:
1507
diff
changeset
|
246 |
LogComponent::Name (void) const |
dd278e20e52e
log verbosity changes
Craig Dowell <craigdo@ee.washington.edu>
parents:
1507
diff
changeset
|
247 |
{ |
dd278e20e52e
log verbosity changes
Craig Dowell <craigdo@ee.washington.edu>
parents:
1507
diff
changeset
|
248 |
return m_name; |
dd278e20e52e
log verbosity changes
Craig Dowell <craigdo@ee.washington.edu>
parents:
1507
diff
changeset
|
249 |
} |
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 |
|
1498
520bc8457799
log rides along for free
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
252 |
void |
520bc8457799
log rides along for free
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
253 |
LogComponentEnable (char const *name, enum LogLevel level) |
520bc8457799
log rides along for free
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
254 |
{ |
520bc8457799
log rides along for free
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
255 |
ComponentList *components = GetComponentList (); |
520bc8457799
log rides along for free
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
256 |
for (ComponentListI i = components->begin (); |
520bc8457799
log rides along for free
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
257 |
i != components->end (); |
520bc8457799
log rides along for free
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
258 |
i++) |
520bc8457799
log rides along for free
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
259 |
{ |
520bc8457799
log rides along for free
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
260 |
if (i->first.compare (name) == 0) |
520bc8457799
log rides along for free
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
261 |
{ |
520bc8457799
log rides along for free
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
262 |
i->second->Enable (level); |
520bc8457799
log rides along for free
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
263 |
break; |
520bc8457799
log rides along for free
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
264 |
} |
520bc8457799
log rides along for free
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
265 |
} |
520bc8457799
log rides along for free
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
266 |
} |
1503
53dd8f414ba6
sorting out logging
Craig Dowell <craigdo@ee.washington.edu>
parents:
1498
diff
changeset
|
267 |
|
1498
520bc8457799
log rides along for free
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
268 |
void |
1772
dd278e20e52e
log verbosity changes
Craig Dowell <craigdo@ee.washington.edu>
parents:
1507
diff
changeset
|
269 |
LogComponentEnableAll (enum LogLevel level) |
dd278e20e52e
log verbosity changes
Craig Dowell <craigdo@ee.washington.edu>
parents:
1507
diff
changeset
|
270 |
{ |
dd278e20e52e
log verbosity changes
Craig Dowell <craigdo@ee.washington.edu>
parents:
1507
diff
changeset
|
271 |
ComponentList *components = GetComponentList (); |
dd278e20e52e
log verbosity changes
Craig Dowell <craigdo@ee.washington.edu>
parents:
1507
diff
changeset
|
272 |
for (ComponentListI i = components->begin (); |
dd278e20e52e
log verbosity changes
Craig Dowell <craigdo@ee.washington.edu>
parents:
1507
diff
changeset
|
273 |
i != components->end (); |
dd278e20e52e
log verbosity changes
Craig Dowell <craigdo@ee.washington.edu>
parents:
1507
diff
changeset
|
274 |
i++) |
dd278e20e52e
log verbosity changes
Craig Dowell <craigdo@ee.washington.edu>
parents:
1507
diff
changeset
|
275 |
{ |
dd278e20e52e
log verbosity changes
Craig Dowell <craigdo@ee.washington.edu>
parents:
1507
diff
changeset
|
276 |
i->second->Enable (level); |
dd278e20e52e
log verbosity changes
Craig Dowell <craigdo@ee.washington.edu>
parents:
1507
diff
changeset
|
277 |
} |
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 |
|
dd278e20e52e
log verbosity changes
Craig Dowell <craigdo@ee.washington.edu>
parents:
1507
diff
changeset
|
280 |
void |
1498
520bc8457799
log rides along for free
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
281 |
LogComponentDisable (char const *name, enum LogLevel level) |
520bc8457799
log rides along for free
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
282 |
{ |
520bc8457799
log rides along for free
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
283 |
ComponentList *components = GetComponentList (); |
520bc8457799
log rides along for free
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
284 |
for (ComponentListI i = components->begin (); |
520bc8457799
log rides along for free
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
285 |
i != components->end (); |
520bc8457799
log rides along for free
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
286 |
i++) |
520bc8457799
log rides along for free
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
287 |
{ |
520bc8457799
log rides along for free
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
288 |
if (i->first.compare (name) == 0) |
520bc8457799
log rides along for free
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
289 |
{ |
520bc8457799
log rides along for free
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
290 |
i->second->Disable (level); |
520bc8457799
log rides along for free
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
291 |
break; |
520bc8457799
log rides along for free
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
292 |
} |
520bc8457799
log rides along for free
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
293 |
} |
520bc8457799
log rides along for free
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
294 |
} |
520bc8457799
log rides along for free
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
295 |
|
520bc8457799
log rides along for free
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
296 |
void |
1772
dd278e20e52e
log verbosity changes
Craig Dowell <craigdo@ee.washington.edu>
parents:
1507
diff
changeset
|
297 |
LogComponentDisableAll (enum LogLevel level) |
dd278e20e52e
log verbosity changes
Craig Dowell <craigdo@ee.washington.edu>
parents:
1507
diff
changeset
|
298 |
{ |
dd278e20e52e
log verbosity changes
Craig Dowell <craigdo@ee.washington.edu>
parents:
1507
diff
changeset
|
299 |
ComponentList *components = GetComponentList (); |
dd278e20e52e
log verbosity changes
Craig Dowell <craigdo@ee.washington.edu>
parents:
1507
diff
changeset
|
300 |
for (ComponentListI i = components->begin (); |
dd278e20e52e
log verbosity changes
Craig Dowell <craigdo@ee.washington.edu>
parents:
1507
diff
changeset
|
301 |
i != components->end (); |
dd278e20e52e
log verbosity changes
Craig Dowell <craigdo@ee.washington.edu>
parents:
1507
diff
changeset
|
302 |
i++) |
dd278e20e52e
log verbosity changes
Craig Dowell <craigdo@ee.washington.edu>
parents:
1507
diff
changeset
|
303 |
{ |
dd278e20e52e
log verbosity changes
Craig Dowell <craigdo@ee.washington.edu>
parents:
1507
diff
changeset
|
304 |
i->second->Disable (level); |
dd278e20e52e
log verbosity changes
Craig Dowell <craigdo@ee.washington.edu>
parents:
1507
diff
changeset
|
305 |
} |
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 |
|
dd278e20e52e
log verbosity changes
Craig Dowell <craigdo@ee.washington.edu>
parents:
1507
diff
changeset
|
308 |
void |
1498
520bc8457799
log rides along for free
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
309 |
LogComponentPrintList (void) |
520bc8457799
log rides along for free
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
310 |
{ |
520bc8457799
log rides along for free
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
311 |
ComponentList *components = GetComponentList (); |
520bc8457799
log rides along for free
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
312 |
for (ComponentListI i = components->begin (); |
520bc8457799
log rides along for free
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
313 |
i != components->end (); |
520bc8457799
log rides along for free
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
314 |
i++) |
520bc8457799
log rides along for free
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
315 |
{ |
520bc8457799
log rides along for free
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
316 |
std::cout << i->first << "="; |
520bc8457799
log rides along for free
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
317 |
if (i->second->IsNoneEnabled ()) |
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 << "0" << std::endl; |
520bc8457799
log rides along for free
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
320 |
continue; |
520bc8457799
log rides along for free
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
321 |
} |
1507
11a370eecc52
allow discrete levels
Craig Dowell <craigdo@ee.washington.edu>
parents:
1506
diff
changeset
|
322 |
if (i->second->IsEnabled (LOG_ERROR)) |
1503
53dd8f414ba6
sorting out logging
Craig Dowell <craigdo@ee.washington.edu>
parents:
1498
diff
changeset
|
323 |
{ |
53dd8f414ba6
sorting out logging
Craig Dowell <craigdo@ee.washington.edu>
parents:
1498
diff
changeset
|
324 |
std::cout << "error"; |
53dd8f414ba6
sorting out logging
Craig Dowell <craigdo@ee.washington.edu>
parents:
1498
diff
changeset
|
325 |
} |
1507
11a370eecc52
allow discrete levels
Craig Dowell <craigdo@ee.washington.edu>
parents:
1506
diff
changeset
|
326 |
if (i->second->IsEnabled (LOG_WARN)) |
1503
53dd8f414ba6
sorting out logging
Craig Dowell <craigdo@ee.washington.edu>
parents:
1498
diff
changeset
|
327 |
{ |
53dd8f414ba6
sorting out logging
Craig Dowell <craigdo@ee.washington.edu>
parents:
1498
diff
changeset
|
328 |
std::cout << "|warn"; |
53dd8f414ba6
sorting out logging
Craig Dowell <craigdo@ee.washington.edu>
parents:
1498
diff
changeset
|
329 |
} |
1507
11a370eecc52
allow discrete levels
Craig Dowell <craigdo@ee.washington.edu>
parents:
1506
diff
changeset
|
330 |
if (i->second->IsEnabled (LOG_DEBUG)) |
1498
520bc8457799
log rides along for free
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
331 |
{ |
1503
53dd8f414ba6
sorting out logging
Craig Dowell <craigdo@ee.washington.edu>
parents:
1498
diff
changeset
|
332 |
std::cout << "|debug"; |
53dd8f414ba6
sorting out logging
Craig Dowell <craigdo@ee.washington.edu>
parents:
1498
diff
changeset
|
333 |
} |
1507
11a370eecc52
allow discrete levels
Craig Dowell <craigdo@ee.washington.edu>
parents:
1506
diff
changeset
|
334 |
if (i->second->IsEnabled (LOG_INFO)) |
1503
53dd8f414ba6
sorting out logging
Craig Dowell <craigdo@ee.washington.edu>
parents:
1498
diff
changeset
|
335 |
{ |
53dd8f414ba6
sorting out logging
Craig Dowell <craigdo@ee.washington.edu>
parents:
1498
diff
changeset
|
336 |
std::cout << "|info"; |
1498
520bc8457799
log rides along for free
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
337 |
} |
1507
11a370eecc52
allow discrete levels
Craig Dowell <craigdo@ee.washington.edu>
parents:
1506
diff
changeset
|
338 |
if (i->second->IsEnabled (LOG_FUNCTION)) |
1498
520bc8457799
log rides along for free
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
339 |
{ |
1503
53dd8f414ba6
sorting out logging
Craig Dowell <craigdo@ee.washington.edu>
parents:
1498
diff
changeset
|
340 |
std::cout << "|function"; |
1498
520bc8457799
log rides along for free
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
341 |
} |
1507
11a370eecc52
allow discrete levels
Craig Dowell <craigdo@ee.washington.edu>
parents:
1506
diff
changeset
|
342 |
if (i->second->IsEnabled (LOG_PARAM)) |
1498
520bc8457799
log rides along for free
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
343 |
{ |
520bc8457799
log rides along for free
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
344 |
std::cout << "|param"; |
520bc8457799
log rides along for free
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
345 |
} |
1507
11a370eecc52
allow discrete levels
Craig Dowell <craigdo@ee.washington.edu>
parents:
1506
diff
changeset
|
346 |
if (i->second->IsEnabled (LOG_LOGIC)) |
1498
520bc8457799
log rides along for free
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
347 |
{ |
1503
53dd8f414ba6
sorting out logging
Craig Dowell <craigdo@ee.washington.edu>
parents:
1498
diff
changeset
|
348 |
std::cout << "|logic"; |
1498
520bc8457799
log rides along for free
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
349 |
} |
1507
11a370eecc52
allow discrete levels
Craig Dowell <craigdo@ee.washington.edu>
parents:
1506
diff
changeset
|
350 |
if (i->second->IsEnabled (LOG_ALL)) |
1498
520bc8457799
log rides along for free
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
351 |
{ |
1503
53dd8f414ba6
sorting out logging
Craig Dowell <craigdo@ee.washington.edu>
parents:
1498
diff
changeset
|
352 |
std::cout << "|all"; |
1498
520bc8457799
log rides along for free
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
353 |
} |
520bc8457799
log rides along for free
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
354 |
std::cout << std::endl; |
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 |
} |
520bc8457799
log rides along for free
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
357 |
|
1828
6ab68edddf45
nicer logging of parameters (bug 79 patch from Gustavo)
Tom Henderson <tomh@tomh.org>
parents:
1783
diff
changeset
|
358 |
|
6ab68edddf45
nicer logging of parameters (bug 79 patch from Gustavo)
Tom Henderson <tomh@tomh.org>
parents:
1783
diff
changeset
|
359 |
ParameterLogger g_parameterLogger; |
6ab68edddf45
nicer logging of parameters (bug 79 patch from Gustavo)
Tom Henderson <tomh@tomh.org>
parents:
1783
diff
changeset
|
360 |
EndParameterListStruct EndParameterList; |
6ab68edddf45
nicer logging of parameters (bug 79 patch from Gustavo)
Tom Henderson <tomh@tomh.org>
parents:
1783
diff
changeset
|
361 |
|
6ab68edddf45
nicer logging of parameters (bug 79 patch from Gustavo)
Tom Henderson <tomh@tomh.org>
parents:
1783
diff
changeset
|
362 |
|
1498
520bc8457799
log rides along for free
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
363 |
} // namespace ns3 |
520bc8457799
log rides along for free
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
364 |
|
1506
3c8b23550e6a
disable log unless debug build
Craig Dowell <craigdo@ee.washington.edu>
parents:
1503
diff
changeset
|
365 |
#endif // NS3_LOG_ENABLE |