author | Vedran Miletić <rivanvx@gmail.com> |
Fri, 28 Dec 2012 04:22:19 +0100 | |
changeset 9214 | 043544eef3ed |
parent 9213 | ab0a5552c994 |
child 9957 | 1a4d84a85bad |
permissions | -rw-r--r-- |
6742
a1759a95842c
convert manual to sphinx format
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
1 |
.. include:: replace.txt |
a1759a95842c
convert manual to sphinx format
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
2 |
|
9213
ab0a5552c994
start the logging chapter of the manual
Tom Henderson <tomh@tomh.org>
parents:
6742
diff
changeset
|
3 |
.. heading hierarchy: |
ab0a5552c994
start the logging chapter of the manual
Tom Henderson <tomh@tomh.org>
parents:
6742
diff
changeset
|
4 |
------------- Chapter |
ab0a5552c994
start the logging chapter of the manual
Tom Henderson <tomh@tomh.org>
parents:
6742
diff
changeset
|
5 |
************* Section (#.#) |
ab0a5552c994
start the logging chapter of the manual
Tom Henderson <tomh@tomh.org>
parents:
6742
diff
changeset
|
6 |
============= Subsection (#.#.#) |
ab0a5552c994
start the logging chapter of the manual
Tom Henderson <tomh@tomh.org>
parents:
6742
diff
changeset
|
7 |
############# Paragraph (no number) |
ab0a5552c994
start the logging chapter of the manual
Tom Henderson <tomh@tomh.org>
parents:
6742
diff
changeset
|
8 |
|
6742
a1759a95842c
convert manual to sphinx format
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
9 |
Logging |
a1759a95842c
convert manual to sphinx format
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
10 |
------- |
a1759a95842c
convert manual to sphinx format
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
11 |
|
9213
ab0a5552c994
start the logging chapter of the manual
Tom Henderson <tomh@tomh.org>
parents:
6742
diff
changeset
|
12 |
The |ns3| logging facility can be used to monitor or debug the progress |
ab0a5552c994
start the logging chapter of the manual
Tom Henderson <tomh@tomh.org>
parents:
6742
diff
changeset
|
13 |
of simulation programs. Logging output can be enabled by program statements |
ab0a5552c994
start the logging chapter of the manual
Tom Henderson <tomh@tomh.org>
parents:
6742
diff
changeset
|
14 |
in your ``main()`` program or by the use of the ``NS_LOG`` environment variable. |
ab0a5552c994
start the logging chapter of the manual
Tom Henderson <tomh@tomh.org>
parents:
6742
diff
changeset
|
15 |
|
ab0a5552c994
start the logging chapter of the manual
Tom Henderson <tomh@tomh.org>
parents:
6742
diff
changeset
|
16 |
Logging statements are not compiled into optimized builds of |ns3|. To use |
ab0a5552c994
start the logging chapter of the manual
Tom Henderson <tomh@tomh.org>
parents:
6742
diff
changeset
|
17 |
logging, one must build the (default) debug build of |ns3|. |
ab0a5552c994
start the logging chapter of the manual
Tom Henderson <tomh@tomh.org>
parents:
6742
diff
changeset
|
18 |
|
ab0a5552c994
start the logging chapter of the manual
Tom Henderson <tomh@tomh.org>
parents:
6742
diff
changeset
|
19 |
The project makes no guarantee about whether logging output will remain |
ab0a5552c994
start the logging chapter of the manual
Tom Henderson <tomh@tomh.org>
parents:
6742
diff
changeset
|
20 |
the same over time. Users are cautioned against building simulation output |
ab0a5552c994
start the logging chapter of the manual
Tom Henderson <tomh@tomh.org>
parents:
6742
diff
changeset
|
21 |
frameworks on top of logging code, as the output and the way the output |
ab0a5552c994
start the logging chapter of the manual
Tom Henderson <tomh@tomh.org>
parents:
6742
diff
changeset
|
22 |
is enabled may change over time. |
ab0a5552c994
start the logging chapter of the manual
Tom Henderson <tomh@tomh.org>
parents:
6742
diff
changeset
|
23 |
|
ab0a5552c994
start the logging chapter of the manual
Tom Henderson <tomh@tomh.org>
parents:
6742
diff
changeset
|
24 |
Logging overview |
ab0a5552c994
start the logging chapter of the manual
Tom Henderson <tomh@tomh.org>
parents:
6742
diff
changeset
|
25 |
**************** |
ab0a5552c994
start the logging chapter of the manual
Tom Henderson <tomh@tomh.org>
parents:
6742
diff
changeset
|
26 |
|
ab0a5552c994
start the logging chapter of the manual
Tom Henderson <tomh@tomh.org>
parents:
6742
diff
changeset
|
27 |
|ns3| logging statements are typically used to log various program |
ab0a5552c994
start the logging chapter of the manual
Tom Henderson <tomh@tomh.org>
parents:
6742
diff
changeset
|
28 |
execution events, such as the occurrence of simulation events or the |
ab0a5552c994
start the logging chapter of the manual
Tom Henderson <tomh@tomh.org>
parents:
6742
diff
changeset
|
29 |
use of a particular function. |
ab0a5552c994
start the logging chapter of the manual
Tom Henderson <tomh@tomh.org>
parents:
6742
diff
changeset
|
30 |
|
ab0a5552c994
start the logging chapter of the manual
Tom Henderson <tomh@tomh.org>
parents:
6742
diff
changeset
|
31 |
For example, this code snippet is from ``Ipv4L3Protocol::IsDestinationAddress()``: |
ab0a5552c994
start the logging chapter of the manual
Tom Henderson <tomh@tomh.org>
parents:
6742
diff
changeset
|
32 |
|
ab0a5552c994
start the logging chapter of the manual
Tom Henderson <tomh@tomh.org>
parents:
6742
diff
changeset
|
33 |
:: |
ab0a5552c994
start the logging chapter of the manual
Tom Henderson <tomh@tomh.org>
parents:
6742
diff
changeset
|
34 |
|
9214
043544eef3ed
Minor fixes and improvements to logging chapter in manual.
Vedran Miletić <rivanvx@gmail.com>
parents:
9213
diff
changeset
|
35 |
if (address == iaddr.GetBroadcast ()) |
043544eef3ed
Minor fixes and improvements to logging chapter in manual.
Vedran Miletić <rivanvx@gmail.com>
parents:
9213
diff
changeset
|
36 |
{ |
043544eef3ed
Minor fixes and improvements to logging chapter in manual.
Vedran Miletić <rivanvx@gmail.com>
parents:
9213
diff
changeset
|
37 |
NS_LOG_LOGIC ("For me (interface broadcast address)"); |
043544eef3ed
Minor fixes and improvements to logging chapter in manual.
Vedran Miletić <rivanvx@gmail.com>
parents:
9213
diff
changeset
|
38 |
return true; |
043544eef3ed
Minor fixes and improvements to logging chapter in manual.
Vedran Miletić <rivanvx@gmail.com>
parents:
9213
diff
changeset
|
39 |
} |
9213
ab0a5552c994
start the logging chapter of the manual
Tom Henderson <tomh@tomh.org>
parents:
6742
diff
changeset
|
40 |
|
ab0a5552c994
start the logging chapter of the manual
Tom Henderson <tomh@tomh.org>
parents:
6742
diff
changeset
|
41 |
If logging has been enabled for the ``Ipv4L3Protocol`` component at a level |
ab0a5552c994
start the logging chapter of the manual
Tom Henderson <tomh@tomh.org>
parents:
6742
diff
changeset
|
42 |
of ``LOGIC`` or above (see below about logging levels), the statement |
ab0a5552c994
start the logging chapter of the manual
Tom Henderson <tomh@tomh.org>
parents:
6742
diff
changeset
|
43 |
will be printed out; otherwise, it will be suppressed. |
ab0a5552c994
start the logging chapter of the manual
Tom Henderson <tomh@tomh.org>
parents:
6742
diff
changeset
|
44 |
|
ab0a5552c994
start the logging chapter of the manual
Tom Henderson <tomh@tomh.org>
parents:
6742
diff
changeset
|
45 |
Logging levels |
ab0a5552c994
start the logging chapter of the manual
Tom Henderson <tomh@tomh.org>
parents:
6742
diff
changeset
|
46 |
============== |
ab0a5552c994
start the logging chapter of the manual
Tom Henderson <tomh@tomh.org>
parents:
6742
diff
changeset
|
47 |
|
ab0a5552c994
start the logging chapter of the manual
Tom Henderson <tomh@tomh.org>
parents:
6742
diff
changeset
|
48 |
The following levels are defined; each level will enable the levels above |
ab0a5552c994
start the logging chapter of the manual
Tom Henderson <tomh@tomh.org>
parents:
6742
diff
changeset
|
49 |
it, with the ``ALL`` level being most verbose: |
ab0a5552c994
start the logging chapter of the manual
Tom Henderson <tomh@tomh.org>
parents:
6742
diff
changeset
|
50 |
|
9214
043544eef3ed
Minor fixes and improvements to logging chapter in manual.
Vedran Miletić <rivanvx@gmail.com>
parents:
9213
diff
changeset
|
51 |
#. ``LOG_NONE``: the default, no logging |
043544eef3ed
Minor fixes and improvements to logging chapter in manual.
Vedran Miletić <rivanvx@gmail.com>
parents:
9213
diff
changeset
|
52 |
#. ``LOG_ERROR``: serious error messages only |
043544eef3ed
Minor fixes and improvements to logging chapter in manual.
Vedran Miletić <rivanvx@gmail.com>
parents:
9213
diff
changeset
|
53 |
#. ``LOG_WARN``: warning messages |
043544eef3ed
Minor fixes and improvements to logging chapter in manual.
Vedran Miletić <rivanvx@gmail.com>
parents:
9213
diff
changeset
|
54 |
#. ``LOG_DEBUG``: for use in debugging |
043544eef3ed
Minor fixes and improvements to logging chapter in manual.
Vedran Miletić <rivanvx@gmail.com>
parents:
9213
diff
changeset
|
55 |
#. ``LOG_FUNCTION``: function tracing |
043544eef3ed
Minor fixes and improvements to logging chapter in manual.
Vedran Miletić <rivanvx@gmail.com>
parents:
9213
diff
changeset
|
56 |
#. ``LOG_LOGIC``: control flow tracing within functions |
043544eef3ed
Minor fixes and improvements to logging chapter in manual.
Vedran Miletić <rivanvx@gmail.com>
parents:
9213
diff
changeset
|
57 |
#. ``LOG_ALL``: print everything |
9213
ab0a5552c994
start the logging chapter of the manual
Tom Henderson <tomh@tomh.org>
parents:
6742
diff
changeset
|
58 |
|
ab0a5552c994
start the logging chapter of the manual
Tom Henderson <tomh@tomh.org>
parents:
6742
diff
changeset
|
59 |
A special logging level will cause logging output to unconditionally |
ab0a5552c994
start the logging chapter of the manual
Tom Henderson <tomh@tomh.org>
parents:
6742
diff
changeset
|
60 |
appear on ``std::clog``, regardless of whether the user has explicitly enabled |
ab0a5552c994
start the logging chapter of the manual
Tom Henderson <tomh@tomh.org>
parents:
6742
diff
changeset
|
61 |
logging. |
ab0a5552c994
start the logging chapter of the manual
Tom Henderson <tomh@tomh.org>
parents:
6742
diff
changeset
|
62 |
This macro, ``NS_LOG_UNCOND()``, can be used like a kind of ``printf()`` in |
ab0a5552c994
start the logging chapter of the manual
Tom Henderson <tomh@tomh.org>
parents:
6742
diff
changeset
|
63 |
your code. An example can be found in ``scratch/scratch-simulator.cc``: |
ab0a5552c994
start the logging chapter of the manual
Tom Henderson <tomh@tomh.org>
parents:
6742
diff
changeset
|
64 |
|
ab0a5552c994
start the logging chapter of the manual
Tom Henderson <tomh@tomh.org>
parents:
6742
diff
changeset
|
65 |
:: |
ab0a5552c994
start the logging chapter of the manual
Tom Henderson <tomh@tomh.org>
parents:
6742
diff
changeset
|
66 |
|
ab0a5552c994
start the logging chapter of the manual
Tom Henderson <tomh@tomh.org>
parents:
6742
diff
changeset
|
67 |
NS_LOG_UNCOND ("Scratch Simulator"); |
ab0a5552c994
start the logging chapter of the manual
Tom Henderson <tomh@tomh.org>
parents:
6742
diff
changeset
|
68 |
|
ab0a5552c994
start the logging chapter of the manual
Tom Henderson <tomh@tomh.org>
parents:
6742
diff
changeset
|
69 |
Logging prefixes |
ab0a5552c994
start the logging chapter of the manual
Tom Henderson <tomh@tomh.org>
parents:
6742
diff
changeset
|
70 |
================ |
ab0a5552c994
start the logging chapter of the manual
Tom Henderson <tomh@tomh.org>
parents:
6742
diff
changeset
|
71 |
|
ab0a5552c994
start the logging chapter of the manual
Tom Henderson <tomh@tomh.org>
parents:
6742
diff
changeset
|
72 |
This section still needs documentation; bug 1496 is open on this: |
ab0a5552c994
start the logging chapter of the manual
Tom Henderson <tomh@tomh.org>
parents:
6742
diff
changeset
|
73 |
|
ab0a5552c994
start the logging chapter of the manual
Tom Henderson <tomh@tomh.org>
parents:
6742
diff
changeset
|
74 |
:: |
ab0a5552c994
start the logging chapter of the manual
Tom Henderson <tomh@tomh.org>
parents:
6742
diff
changeset
|
75 |
|
ab0a5552c994
start the logging chapter of the manual
Tom Henderson <tomh@tomh.org>
parents:
6742
diff
changeset
|
76 |
$ NS_LOG="*=all|prefix_all" ./waf --run scratch-simulator |
ab0a5552c994
start the logging chapter of the manual
Tom Henderson <tomh@tomh.org>
parents:
6742
diff
changeset
|
77 |
Scratch Simulator |
ab0a5552c994
start the logging chapter of the manual
Tom Henderson <tomh@tomh.org>
parents:
6742
diff
changeset
|
78 |
ScratchSimulator:main(): [ERROR] error message |
ab0a5552c994
start the logging chapter of the manual
Tom Henderson <tomh@tomh.org>
parents:
6742
diff
changeset
|
79 |
ScratchSimulator:main(): [WARN] warn message |
ab0a5552c994
start the logging chapter of the manual
Tom Henderson <tomh@tomh.org>
parents:
6742
diff
changeset
|
80 |
ScratchSimulator:main(): [DEBUG] debug message |
ab0a5552c994
start the logging chapter of the manual
Tom Henderson <tomh@tomh.org>
parents:
6742
diff
changeset
|
81 |
ScratchSimulator:main(): [INFO] info message |
ab0a5552c994
start the logging chapter of the manual
Tom Henderson <tomh@tomh.org>
parents:
6742
diff
changeset
|
82 |
ScratchSimulator:main(function) |
ab0a5552c994
start the logging chapter of the manual
Tom Henderson <tomh@tomh.org>
parents:
6742
diff
changeset
|
83 |
ScratchSimulator:main(): [LOGIC] logic message |
ab0a5552c994
start the logging chapter of the manual
Tom Henderson <tomh@tomh.org>
parents:
6742
diff
changeset
|
84 |
|
ab0a5552c994
start the logging chapter of the manual
Tom Henderson <tomh@tomh.org>
parents:
6742
diff
changeset
|
85 |
Enabling logging output |
ab0a5552c994
start the logging chapter of the manual
Tom Henderson <tomh@tomh.org>
parents:
6742
diff
changeset
|
86 |
======================= |
ab0a5552c994
start the logging chapter of the manual
Tom Henderson <tomh@tomh.org>
parents:
6742
diff
changeset
|
87 |
|
ab0a5552c994
start the logging chapter of the manual
Tom Henderson <tomh@tomh.org>
parents:
6742
diff
changeset
|
88 |
There are two ways that users typically control logging output. The |
ab0a5552c994
start the logging chapter of the manual
Tom Henderson <tomh@tomh.org>
parents:
6742
diff
changeset
|
89 |
first is by setting an ``NS_LOG`` environment variable; e.g.: |
ab0a5552c994
start the logging chapter of the manual
Tom Henderson <tomh@tomh.org>
parents:
6742
diff
changeset
|
90 |
|
ab0a5552c994
start the logging chapter of the manual
Tom Henderson <tomh@tomh.org>
parents:
6742
diff
changeset
|
91 |
:: |
ab0a5552c994
start the logging chapter of the manual
Tom Henderson <tomh@tomh.org>
parents:
6742
diff
changeset
|
92 |
|
ab0a5552c994
start the logging chapter of the manual
Tom Henderson <tomh@tomh.org>
parents:
6742
diff
changeset
|
93 |
NS_LOG="*" ./waf --run first |
ab0a5552c994
start the logging chapter of the manual
Tom Henderson <tomh@tomh.org>
parents:
6742
diff
changeset
|
94 |
|
ab0a5552c994
start the logging chapter of the manual
Tom Henderson <tomh@tomh.org>
parents:
6742
diff
changeset
|
95 |
will run the first tutorial program with all logging output. This can |
ab0a5552c994
start the logging chapter of the manual
Tom Henderson <tomh@tomh.org>
parents:
6742
diff
changeset
|
96 |
be made more granular by selecting individual components: |
ab0a5552c994
start the logging chapter of the manual
Tom Henderson <tomh@tomh.org>
parents:
6742
diff
changeset
|
97 |
|
ab0a5552c994
start the logging chapter of the manual
Tom Henderson <tomh@tomh.org>
parents:
6742
diff
changeset
|
98 |
:: |
ab0a5552c994
start the logging chapter of the manual
Tom Henderson <tomh@tomh.org>
parents:
6742
diff
changeset
|
99 |
|
ab0a5552c994
start the logging chapter of the manual
Tom Henderson <tomh@tomh.org>
parents:
6742
diff
changeset
|
100 |
NS_LOG="Ipv4L3Protocol" ./waf --run first |
ab0a5552c994
start the logging chapter of the manual
Tom Henderson <tomh@tomh.org>
parents:
6742
diff
changeset
|
101 |
|
ab0a5552c994
start the logging chapter of the manual
Tom Henderson <tomh@tomh.org>
parents:
6742
diff
changeset
|
102 |
The second way to enable this is to use explicit statements in your |
ab0a5552c994
start the logging chapter of the manual
Tom Henderson <tomh@tomh.org>
parents:
6742
diff
changeset
|
103 |
program, such as in the first tutorial program: |
ab0a5552c994
start the logging chapter of the manual
Tom Henderson <tomh@tomh.org>
parents:
6742
diff
changeset
|
104 |
|
ab0a5552c994
start the logging chapter of the manual
Tom Henderson <tomh@tomh.org>
parents:
6742
diff
changeset
|
105 |
:: |
ab0a5552c994
start the logging chapter of the manual
Tom Henderson <tomh@tomh.org>
parents:
6742
diff
changeset
|
106 |
|
ab0a5552c994
start the logging chapter of the manual
Tom Henderson <tomh@tomh.org>
parents:
6742
diff
changeset
|
107 |
int |
ab0a5552c994
start the logging chapter of the manual
Tom Henderson <tomh@tomh.org>
parents:
6742
diff
changeset
|
108 |
main (int argc, char *argv[]) |
ab0a5552c994
start the logging chapter of the manual
Tom Henderson <tomh@tomh.org>
parents:
6742
diff
changeset
|
109 |
{ |
ab0a5552c994
start the logging chapter of the manual
Tom Henderson <tomh@tomh.org>
parents:
6742
diff
changeset
|
110 |
LogComponentEnable ("UdpEchoClientApplication", LOG_LEVEL_INFO); |
ab0a5552c994
start the logging chapter of the manual
Tom Henderson <tomh@tomh.org>
parents:
6742
diff
changeset
|
111 |
LogComponentEnable ("UdpEchoServerApplication", LOG_LEVEL_INFO); |
9214
043544eef3ed
Minor fixes and improvements to logging chapter in manual.
Vedran Miletić <rivanvx@gmail.com>
parents:
9213
diff
changeset
|
112 |
... |
9213
ab0a5552c994
start the logging chapter of the manual
Tom Henderson <tomh@tomh.org>
parents:
6742
diff
changeset
|
113 |
|
ab0a5552c994
start the logging chapter of the manual
Tom Henderson <tomh@tomh.org>
parents:
6742
diff
changeset
|
114 |
Some helpers have special methods to enable the logging of all components |
ab0a5552c994
start the logging chapter of the manual
Tom Henderson <tomh@tomh.org>
parents:
6742
diff
changeset
|
115 |
in a module (across different compilation units, but logically grouped |
ab0a5552c994
start the logging chapter of the manual
Tom Henderson <tomh@tomh.org>
parents:
6742
diff
changeset
|
116 |
together such as the |ns3| wifi code: |
ab0a5552c994
start the logging chapter of the manual
Tom Henderson <tomh@tomh.org>
parents:
6742
diff
changeset
|
117 |
|
ab0a5552c994
start the logging chapter of the manual
Tom Henderson <tomh@tomh.org>
parents:
6742
diff
changeset
|
118 |
:: |
ab0a5552c994
start the logging chapter of the manual
Tom Henderson <tomh@tomh.org>
parents:
6742
diff
changeset
|
119 |
|
ab0a5552c994
start the logging chapter of the manual
Tom Henderson <tomh@tomh.org>
parents:
6742
diff
changeset
|
120 |
WifiHelper wifiHelper; |
ab0a5552c994
start the logging chapter of the manual
Tom Henderson <tomh@tomh.org>
parents:
6742
diff
changeset
|
121 |
wifiHelper.EnableLogComponents (); |
ab0a5552c994
start the logging chapter of the manual
Tom Henderson <tomh@tomh.org>
parents:
6742
diff
changeset
|
122 |
|
ab0a5552c994
start the logging chapter of the manual
Tom Henderson <tomh@tomh.org>
parents:
6742
diff
changeset
|
123 |
|
ab0a5552c994
start the logging chapter of the manual
Tom Henderson <tomh@tomh.org>
parents:
6742
diff
changeset
|
124 |
How to add logging to your code |
ab0a5552c994
start the logging chapter of the manual
Tom Henderson <tomh@tomh.org>
parents:
6742
diff
changeset
|
125 |
******************************* |
ab0a5552c994
start the logging chapter of the manual
Tom Henderson <tomh@tomh.org>
parents:
6742
diff
changeset
|
126 |
|
ab0a5552c994
start the logging chapter of the manual
Tom Henderson <tomh@tomh.org>
parents:
6742
diff
changeset
|
127 |
To add logging to your code, please follow the below steps: |
ab0a5552c994
start the logging chapter of the manual
Tom Henderson <tomh@tomh.org>
parents:
6742
diff
changeset
|
128 |
|
ab0a5552c994
start the logging chapter of the manual
Tom Henderson <tomh@tomh.org>
parents:
6742
diff
changeset
|
129 |
1) Put ``NS_LOG_COMPONENT_DEFINE`` macro outside of namespace ns3 |
ab0a5552c994
start the logging chapter of the manual
Tom Henderson <tomh@tomh.org>
parents:
6742
diff
changeset
|
130 |
|
9214
043544eef3ed
Minor fixes and improvements to logging chapter in manual.
Vedran Miletić <rivanvx@gmail.com>
parents:
9213
diff
changeset
|
131 |
Create a unique string identifier (usually based on the name of the file |
043544eef3ed
Minor fixes and improvements to logging chapter in manual.
Vedran Miletić <rivanvx@gmail.com>
parents:
9213
diff
changeset
|
132 |
and/or class defined within the file) and register it with a macro call |
043544eef3ed
Minor fixes and improvements to logging chapter in manual.
Vedran Miletić <rivanvx@gmail.com>
parents:
9213
diff
changeset
|
133 |
such as follows: |
9213
ab0a5552c994
start the logging chapter of the manual
Tom Henderson <tomh@tomh.org>
parents:
6742
diff
changeset
|
134 |
|
ab0a5552c994
start the logging chapter of the manual
Tom Henderson <tomh@tomh.org>
parents:
6742
diff
changeset
|
135 |
:: |
ab0a5552c994
start the logging chapter of the manual
Tom Henderson <tomh@tomh.org>
parents:
6742
diff
changeset
|
136 |
|
ab0a5552c994
start the logging chapter of the manual
Tom Henderson <tomh@tomh.org>
parents:
6742
diff
changeset
|
137 |
NS_LOG_COMPONENT_DEFINE ("Ipv4L3Protocol"); |
ab0a5552c994
start the logging chapter of the manual
Tom Henderson <tomh@tomh.org>
parents:
6742
diff
changeset
|
138 |
|
ab0a5552c994
start the logging chapter of the manual
Tom Henderson <tomh@tomh.org>
parents:
6742
diff
changeset
|
139 |
namespace ns3 { |
ab0a5552c994
start the logging chapter of the manual
Tom Henderson <tomh@tomh.org>
parents:
6742
diff
changeset
|
140 |
... |
ab0a5552c994
start the logging chapter of the manual
Tom Henderson <tomh@tomh.org>
parents:
6742
diff
changeset
|
141 |
|
ab0a5552c994
start the logging chapter of the manual
Tom Henderson <tomh@tomh.org>
parents:
6742
diff
changeset
|
142 |
The macro was carefully written to permit inclusion either within or |
9214
043544eef3ed
Minor fixes and improvements to logging chapter in manual.
Vedran Miletić <rivanvx@gmail.com>
parents:
9213
diff
changeset
|
143 |
outside of namespace ``ns3``, and usage will vary across the codebase, but |
043544eef3ed
Minor fixes and improvements to logging chapter in manual.
Vedran Miletić <rivanvx@gmail.com>
parents:
9213
diff
changeset
|
144 |
the original intent was to register this *outside* of namespace ``ns3``. |
9213
ab0a5552c994
start the logging chapter of the manual
Tom Henderson <tomh@tomh.org>
parents:
6742
diff
changeset
|
145 |
|
ab0a5552c994
start the logging chapter of the manual
Tom Henderson <tomh@tomh.org>
parents:
6742
diff
changeset
|
146 |
2) Add logging statements to your functions and function bodies. |
ab0a5552c994
start the logging chapter of the manual
Tom Henderson <tomh@tomh.org>
parents:
6742
diff
changeset
|
147 |
|
ab0a5552c994
start the logging chapter of the manual
Tom Henderson <tomh@tomh.org>
parents:
6742
diff
changeset
|
148 |
There are a couple of guidelines on this: |
ab0a5552c994
start the logging chapter of the manual
Tom Henderson <tomh@tomh.org>
parents:
6742
diff
changeset
|
149 |
|
9214
043544eef3ed
Minor fixes and improvements to logging chapter in manual.
Vedran Miletić <rivanvx@gmail.com>
parents:
9213
diff
changeset
|
150 |
* Do *not* add function logging in operators or explicit copy constructors, |
9213
ab0a5552c994
start the logging chapter of the manual
Tom Henderson <tomh@tomh.org>
parents:
6742
diff
changeset
|
151 |
since these will cause infinite recursion and stack overflow. |
9214
043544eef3ed
Minor fixes and improvements to logging chapter in manual.
Vedran Miletić <rivanvx@gmail.com>
parents:
9213
diff
changeset
|
152 |
* Use the ``NS_LOG_FUNCTION_NOARGS()`` variant for static methods *only*. When |
043544eef3ed
Minor fixes and improvements to logging chapter in manual.
Vedran Miletić <rivanvx@gmail.com>
parents:
9213
diff
changeset
|
153 |
a non-static member function has no arguments, it should be logged by |
043544eef3ed
Minor fixes and improvements to logging chapter in manual.
Vedran Miletić <rivanvx@gmail.com>
parents:
9213
diff
changeset
|
154 |
``NS_LOG_FUNCTION (this)`` macro. |
9213
ab0a5552c994
start the logging chapter of the manual
Tom Henderson <tomh@tomh.org>
parents:
6742
diff
changeset
|
155 |
* Make sure that you test that your logging changes do not break the code; |
ab0a5552c994
start the logging chapter of the manual
Tom Henderson <tomh@tomh.org>
parents:
6742
diff
changeset
|
156 |
running some example programs with all log components turned on (e.g. |
ab0a5552c994
start the logging chapter of the manual
Tom Henderson <tomh@tomh.org>
parents:
6742
diff
changeset
|
157 |
``NS_LOG="*"``) is one way to test this. |
ab0a5552c994
start the logging chapter of the manual
Tom Henderson <tomh@tomh.org>
parents:
6742
diff
changeset
|
158 |