src/core/model/log.h
author Andrey Mazo <ahippo@yandex.com>
Sun, 23 Mar 2014 19:08:54 +0400
changeset 10687 1330d4ee94e8
parent 10654 0148f9c47331
child 10974 bca3ca8862ff
permissions -rw-r--r--
Bug 1170: Formulate best practices for dealing with unused debug variables. Fixed clang-3.4 unused function warnings in optimized builds like the following: """ ../examples/energy/energy-model-example.cc:39:1: error: unused function 'PrintReceivedPacket' [-Werror,-Wunused-function] PrintReceivedPacket (Address& from) ^ 1 error generated. """ Implemented "if (false)" trick inside NS_LOG* macros for optimized builds. "sizeof()" trick might be a little better but it produces the following warning with clang-3.4: """ ../examples/energy/energy-model-example.cc:39:1: error: function 'PrintReceivedPacket' is not needed and will not be emitted [-Werror,-Wunneeded-internal-declaration] PrintReceivedPacket (Address& from) ^ 1 error generated. """ Macros from log.h, that depend on NS3_LOG_ENABLE, were moved to log-macros-enabled.h and log-macros-disabled.h to make log.h smaller.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
1498
520bc8457799 log rides along for free
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
     1
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
520bc8457799 log rides along for free
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
     2
/*
520bc8457799 log rides along for free
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
     3
 * Copyright (c) 2006,2007 INRIA
520bc8457799 log rides along for free
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
     4
 *
520bc8457799 log rides along for free
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
     5
 * This program is free software; you can redistribute it and/or modify
520bc8457799 log rides along for free
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
     6
 * it under the terms of the GNU General Public License version 2 as
520bc8457799 log rides along for free
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
     7
 * published by the Free Software Foundation;
520bc8457799 log rides along for free
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
     8
 *
520bc8457799 log rides along for free
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
     9
 * This program is distributed in the hope that it will be useful,
520bc8457799 log rides along for free
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    10
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
520bc8457799 log rides along for free
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    11
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
520bc8457799 log rides along for free
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    12
 * GNU General Public License for more details.
520bc8457799 log rides along for free
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    13
 *
520bc8457799 log rides along for free
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    14
 * You should have received a copy of the GNU General Public License
520bc8457799 log rides along for free
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    15
 * along with this program; if not, write to the Free Software
520bc8457799 log rides along for free
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    16
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
520bc8457799 log rides along for free
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    17
 *
520bc8457799 log rides along for free
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    18
 * Author: Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
520bc8457799 log rides along for free
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    19
 */
1506
3c8b23550e6a disable log unless debug build
Craig Dowell <craigdo@ee.washington.edu>
parents: 1504
diff changeset
    20
9184
065a297f6c9d bug 1531: Crash when using NS_LOG in destructors of static objects
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 9119
diff changeset
    21
#ifndef NS3_LOG_H
065a297f6c9d bug 1531: Crash when using NS_LOG in destructors of static objects
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 9119
diff changeset
    22
#define NS3_LOG_H
1498
520bc8457799 log rides along for free
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    23
520bc8457799 log rides along for free
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    24
#include <string>
520bc8457799 log rides along for free
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    25
#include <iostream>
4353
596eb8034443 bug 552: build with gcc 4.4
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3530
diff changeset
    26
#include <stdint.h>
9119
9c0cc3997ece [Bug 1496] Print the LOG_LEVEL (severity) in NS_LOG messages.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 8995
diff changeset
    27
#include <map>
1498
520bc8457799 log rides along for free
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    28
10687
1330d4ee94e8 Bug 1170: Formulate best practices for dealing with unused debug variables.
Andrey Mazo <ahippo@yandex.com>
parents: 10654
diff changeset
    29
#include "log-macros-enabled.h"
1330d4ee94e8 Bug 1170: Formulate best practices for dealing with unused debug variables.
Andrey Mazo <ahippo@yandex.com>
parents: 10654
diff changeset
    30
#include "log-macros-disabled.h"
1330d4ee94e8 Bug 1170: Formulate best practices for dealing with unused debug variables.
Andrey Mazo <ahippo@yandex.com>
parents: 10654
diff changeset
    31
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: 3182
diff changeset
    32
namespace ns3 {
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: 3182
diff changeset
    33
10516
f70e78d94658 [Bug 1496] Finish the documentation.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 10411
diff changeset
    34
/**
f70e78d94658 [Bug 1496] Finish the documentation.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 10411
diff changeset
    35
 * \ingroup debugging
f70e78d94658 [Bug 1496] Finish the documentation.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 10411
diff changeset
    36
 * \defgroup logging Logging
10654
0148f9c47331 [doxygen] Make introspected lists more visible, various other doxy
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 10651
diff changeset
    37
 *
10516
f70e78d94658 [Bug 1496] Finish the documentation.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 10411
diff changeset
    38
 * \brief Logging functions and macros
f70e78d94658 [Bug 1496] Finish the documentation.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 10411
diff changeset
    39
 *
f70e78d94658 [Bug 1496] Finish the documentation.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 10411
diff changeset
    40
 * LOG functionality: macros which allow developers to
f70e78d94658 [Bug 1496] Finish the documentation.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 10411
diff changeset
    41
 * send information to the std::clog output stream. All logging messages 
f70e78d94658 [Bug 1496] Finish the documentation.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 10411
diff changeset
    42
 * are disabled by default. To enable selected logging 
f70e78d94658 [Bug 1496] Finish the documentation.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 10411
diff changeset
    43
 * messages, use the ns3::LogComponentEnable
f70e78d94658 [Bug 1496] Finish the documentation.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 10411
diff changeset
    44
 * function or use the NS_LOG environment variable 
f70e78d94658 [Bug 1496] Finish the documentation.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 10411
diff changeset
    45
 *
f70e78d94658 [Bug 1496] Finish the documentation.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 10411
diff changeset
    46
 * Use the environment variable NS_LOG to define a ':'-separated list of
f70e78d94658 [Bug 1496] Finish the documentation.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 10411
diff changeset
    47
 * logging components to enable. For example (using bash syntax), 
f70e78d94658 [Bug 1496] Finish the documentation.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 10411
diff changeset
    48
 * NS_LOG="OlsrAgent" would enable one component at all log levels. 
f70e78d94658 [Bug 1496] Finish the documentation.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 10411
diff changeset
    49
 * NS_LOG="OlsrAgent:Ipv4L3Protocol" would enable two components, 
f70e78d94658 [Bug 1496] Finish the documentation.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 10411
diff changeset
    50
 * at all log levels, etc.
f70e78d94658 [Bug 1496] Finish the documentation.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 10411
diff changeset
    51
 * NS_LOG="*" will enable all available log components at all levels.
f70e78d94658 [Bug 1496] Finish the documentation.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 10411
diff changeset
    52
 *
f70e78d94658 [Bug 1496] Finish the documentation.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 10411
diff changeset
    53
 * To control more selectively the log levels for each component, use
f70e78d94658 [Bug 1496] Finish the documentation.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 10411
diff changeset
    54
 * this syntax: NS_LOG='Component1=func|warn:Component2=error|debug'
f70e78d94658 [Bug 1496] Finish the documentation.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 10411
diff changeset
    55
 * This example would enable the 'func', and 'warn' log
f70e78d94658 [Bug 1496] Finish the documentation.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 10411
diff changeset
    56
 * levels for 'Component1' and the 'error' and 'debug' log levels
f70e78d94658 [Bug 1496] Finish the documentation.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 10411
diff changeset
    57
 * for 'Component2'.  The wildcard can be used here as well.  For example
f70e78d94658 [Bug 1496] Finish the documentation.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 10411
diff changeset
    58
 * NS_LOG='*=level_all|prefix' would enable all log levels and prefix all
f70e78d94658 [Bug 1496] Finish the documentation.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 10411
diff changeset
    59
 * prints with the component and function names.
f70e78d94658 [Bug 1496] Finish the documentation.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 10411
diff changeset
    60
 *
f70e78d94658 [Bug 1496] Finish the documentation.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 10411
diff changeset
    61
 * A note on NS_LOG_FUNCTION() and NS_LOG_FUNCTION_NOARGS():
f70e78d94658 [Bug 1496] Finish the documentation.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 10411
diff changeset
    62
 * generally, use of (at least) NS_LOG_FUNCTION(this) is preferred.
f70e78d94658 [Bug 1496] Finish the documentation.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 10411
diff changeset
    63
 * Use NS_LOG_FUNCTION_NOARGS() only in static functions.
f70e78d94658 [Bug 1496] Finish the documentation.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 10411
diff changeset
    64
 */
f70e78d94658 [Bug 1496] Finish the documentation.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 10411
diff changeset
    65
f70e78d94658 [Bug 1496] Finish the documentation.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 10411
diff changeset
    66
/**
f70e78d94658 [Bug 1496] Finish the documentation.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 10411
diff changeset
    67
 *  \ingroup logging
f70e78d94658 [Bug 1496] Finish the documentation.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 10411
diff changeset
    68
 *
f70e78d94658 [Bug 1496] Finish the documentation.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 10411
diff changeset
    69
 *  Logging severity classes and levels.
f70e78d94658 [Bug 1496] Finish the documentation.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 10411
diff changeset
    70
 */
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: 3182
diff changeset
    71
enum LogLevel {
10626
16bbfc4cb29d [Bug 1862] NS_LOG="Time=*|prefix_time" causes stack overflow
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 10625
diff changeset
    72
  LOG_NONE           = 0x00000000, //!< no logging
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: 3182
diff changeset
    73
10626
16bbfc4cb29d [Bug 1862] NS_LOG="Time=*|prefix_time" causes stack overflow
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 10625
diff changeset
    74
  LOG_ERROR          = 0x00000001, //!< serious error messages only
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: 3182
diff changeset
    75
  LOG_LEVEL_ERROR    = 0x00000001,
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: 3182
diff changeset
    76
10626
16bbfc4cb29d [Bug 1862] NS_LOG="Time=*|prefix_time" causes stack overflow
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 10625
diff changeset
    77
  LOG_WARN           = 0x00000002, //!< warning messages
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: 3182
diff changeset
    78
  LOG_LEVEL_WARN     = 0x00000003,
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: 3182
diff changeset
    79
10626
16bbfc4cb29d [Bug 1862] NS_LOG="Time=*|prefix_time" causes stack overflow
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 10625
diff changeset
    80
  LOG_DEBUG          = 0x00000004, //!< rare ad-hoc debug messages
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: 3182
diff changeset
    81
  LOG_LEVEL_DEBUG    = 0x00000007,
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: 3182
diff changeset
    82
10626
16bbfc4cb29d [Bug 1862] NS_LOG="Time=*|prefix_time" causes stack overflow
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 10625
diff changeset
    83
  LOG_INFO           = 0x00000008, //!< informational messages (e.g., banners)
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: 3182
diff changeset
    84
  LOG_LEVEL_INFO     = 0x0000000f,
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: 3182
diff changeset
    85
10626
16bbfc4cb29d [Bug 1862] NS_LOG="Time=*|prefix_time" causes stack overflow
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 10625
diff changeset
    86
  LOG_FUNCTION       = 0x00000010, //!< function tracing
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: 3182
diff changeset
    87
  LOG_LEVEL_FUNCTION = 0x0000001f, 
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: 3182
diff changeset
    88
10626
16bbfc4cb29d [Bug 1862] NS_LOG="Time=*|prefix_time" causes stack overflow
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 10625
diff changeset
    89
  LOG_LOGIC          = 0x00000020, //!< control flow tracing within functions
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: 3182
diff changeset
    90
  LOG_LEVEL_LOGIC    = 0x0000003f,
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: 3182
diff changeset
    91
10626
16bbfc4cb29d [Bug 1862] NS_LOG="Time=*|prefix_time" causes stack overflow
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 10625
diff changeset
    92
  LOG_ALL            = 0x0fffffff, //!< print everything
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: 3182
diff changeset
    93
  LOG_LEVEL_ALL      = LOG_ALL,
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: 3182
diff changeset
    94
10626
16bbfc4cb29d [Bug 1862] NS_LOG="Time=*|prefix_time" causes stack overflow
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 10625
diff changeset
    95
  LOG_PREFIX_FUNC    = 0x80000000, //!< prefix all trace prints with function
16bbfc4cb29d [Bug 1862] NS_LOG="Time=*|prefix_time" causes stack overflow
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 10625
diff changeset
    96
  LOG_PREFIX_TIME    = 0x40000000, //!< prefix all trace prints with simulation time
16bbfc4cb29d [Bug 1862] NS_LOG="Time=*|prefix_time" causes stack overflow
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 10625
diff changeset
    97
  LOG_PREFIX_NODE    = 0x20000000, //!< prefix all trace prints with simulation node
16bbfc4cb29d [Bug 1862] NS_LOG="Time=*|prefix_time" causes stack overflow
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 10625
diff changeset
    98
  LOG_PREFIX_LEVEL   = 0x10000000, //!< prefix all trace prints with log level (severity)
16bbfc4cb29d [Bug 1862] NS_LOG="Time=*|prefix_time" causes stack overflow
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 10625
diff changeset
    99
  LOG_PREFIX_ALL     = 0xf0000000  //!< all prefixes
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: 3182
diff changeset
   100
};
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: 3182
diff changeset
   101
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: 3182
diff changeset
   102
/**
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: 3182
diff changeset
   103
 * \ingroup logging
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: 3182
diff changeset
   104
 *
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: 3182
diff changeset
   105
 * Enable the logging output associated with that log component.
10654
0148f9c47331 [doxygen] Make introspected lists more visible, various other doxy
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 10651
diff changeset
   106
 *
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: 3182
diff changeset
   107
 * The logging output can be later disabled with a call
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: 3182
diff changeset
   108
 * to ns3::LogComponentDisable.
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: 3182
diff changeset
   109
 *
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: 3182
diff changeset
   110
 * Same as running your program with the NS_LOG environment
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: 3182
diff changeset
   111
 * variable set as NS_LOG='name=level'
10654
0148f9c47331 [doxygen] Make introspected lists more visible, various other doxy
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 10651
diff changeset
   112
 *
0148f9c47331 [doxygen] Make introspected lists more visible, various other doxy
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 10651
diff changeset
   113
 * \param name a log component name
0148f9c47331 [doxygen] Make introspected lists more visible, various other doxy
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 10651
diff changeset
   114
 * \param level a logging level
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: 3182
diff changeset
   115
 */
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: 3182
diff changeset
   116
void LogComponentEnable (char const *name, enum LogLevel level);
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: 3182
diff changeset
   117
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: 3182
diff changeset
   118
/**
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: 3182
diff changeset
   119
 * \ingroup logging
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: 3182
diff changeset
   120
 *
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: 3182
diff changeset
   121
 * Enable the logging output for all registered log components.
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: 3182
diff changeset
   122
 *
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: 3182
diff changeset
   123
 * Same as running your program with the NS_LOG environment
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: 3182
diff changeset
   124
 * variable set as NS_LOG='*=level'
10654
0148f9c47331 [doxygen] Make introspected lists more visible, various other doxy
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 10651
diff changeset
   125
 *
0148f9c47331 [doxygen] Make introspected lists more visible, various other doxy
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 10651
diff changeset
   126
 * \param level a logging level
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: 3182
diff changeset
   127
 */
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: 3182
diff changeset
   128
void LogComponentEnableAll (enum LogLevel level);
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: 3182
diff changeset
   129
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: 3182
diff changeset
   130
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: 3182
diff changeset
   131
/**
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: 3182
diff changeset
   132
 * \ingroup logging
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: 3182
diff changeset
   133
 *
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: 3182
diff changeset
   134
 * Disable the logging output associated with that log component.
10654
0148f9c47331 [doxygen] Make introspected lists more visible, various other doxy
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 10651
diff changeset
   135
 *
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: 3182
diff changeset
   136
 * The logging output can be later re-enabled with a call
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: 3182
diff changeset
   137
 * to ns3::LogComponentEnable.
10654
0148f9c47331 [doxygen] Make introspected lists more visible, various other doxy
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 10651
diff changeset
   138
 *
0148f9c47331 [doxygen] Make introspected lists more visible, various other doxy
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 10651
diff changeset
   139
 * \param name a log component name
0148f9c47331 [doxygen] Make introspected lists more visible, various other doxy
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 10651
diff changeset
   140
 * \param level a logging level
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: 3182
diff changeset
   141
 */
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: 3182
diff changeset
   142
void LogComponentDisable (char const *name, enum LogLevel level);
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: 3182
diff changeset
   143
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: 3182
diff changeset
   144
/**
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: 3182
diff changeset
   145
 * \ingroup logging
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: 3182
diff changeset
   146
 *
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: 3182
diff changeset
   147
 * Disable all logging for all components.
10654
0148f9c47331 [doxygen] Make introspected lists more visible, various other doxy
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 10651
diff changeset
   148
 *
0148f9c47331 [doxygen] Make introspected lists more visible, various other doxy
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 10651
diff changeset
   149
 * \param level a logging level
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: 3182
diff changeset
   150
 */
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: 3182
diff changeset
   151
void LogComponentDisableAll (enum LogLevel level);
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: 3182
diff changeset
   152
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: 3182
diff changeset
   153
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: 3182
diff changeset
   154
} // namespace ns3
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: 3182
diff changeset
   155
1498
520bc8457799 log rides along for free
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   156
/**
520bc8457799 log rides along for free
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   157
 * \ingroup logging
520bc8457799 log rides along for free
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   158
 *
10411
f5916669dbe7 [doxygen] Suppress "warning: Member NS_LOG_COMPONENT_DEFINE is not documented"
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 10228
diff changeset
   159
 * Define a Log component with a specific name.
f5916669dbe7 [doxygen] Suppress "warning: Member NS_LOG_COMPONENT_DEFINE is not documented"
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 10228
diff changeset
   160
 *
f5916669dbe7 [doxygen] Suppress "warning: Member NS_LOG_COMPONENT_DEFINE is not documented"
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 10228
diff changeset
   161
 * This macro should be used at the top of every file in which you want 
1498
520bc8457799 log rides along for free
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   162
 * to use the NS_LOG macro. This macro defines a new
520bc8457799 log rides along for free
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   163
 * "log component" which can be later selectively enabled
520bc8457799 log rides along for free
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   164
 * or disabled with the ns3::LogComponentEnable and 
520bc8457799 log rides along for free
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   165
 * ns3::LogComponentDisable functions or with the NS_LOG
520bc8457799 log rides along for free
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   166
 * environment variable.
10411
f5916669dbe7 [doxygen] Suppress "warning: Member NS_LOG_COMPONENT_DEFINE is not documented"
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 10228
diff changeset
   167
 *
10626
16bbfc4cb29d [Bug 1862] NS_LOG="Time=*|prefix_time" causes stack overflow
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 10625
diff changeset
   168
 * \param name a string
1498
520bc8457799 log rides along for free
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   169
 */
2979
3d39dd617b8d add time logging support
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2978
diff changeset
   170
#define NS_LOG_COMPONENT_DEFINE(name)                           \
1498
520bc8457799 log rides along for free
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   171
  static ns3::LogComponent g_log = ns3::LogComponent (name)
520bc8457799 log rides along for free
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   172
10516
f70e78d94658 [Bug 1496] Finish the documentation.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 10411
diff changeset
   173
/**
f70e78d94658 [Bug 1496] Finish the documentation.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 10411
diff changeset
   174
 * \ingroup logging
10626
16bbfc4cb29d [Bug 1862] NS_LOG="Time=*|prefix_time" causes stack overflow
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 10625
diff changeset
   175
 *
10654
0148f9c47331 [doxygen] Make introspected lists more visible, various other doxy
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 10651
diff changeset
   176
 * Define a logging component with a mask.
0148f9c47331 [doxygen] Make introspected lists more visible, various other doxy
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 10651
diff changeset
   177
 *
0148f9c47331 [doxygen] Make introspected lists more visible, various other doxy
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 10651
diff changeset
   178
 * See LogComponent().
10626
16bbfc4cb29d [Bug 1862] NS_LOG="Time=*|prefix_time" causes stack overflow
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 10625
diff changeset
   179
 *
16bbfc4cb29d [Bug 1862] NS_LOG="Time=*|prefix_time" causes stack overflow
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 10625
diff changeset
   180
 * \param name a string
16bbfc4cb29d [Bug 1862] NS_LOG="Time=*|prefix_time" causes stack overflow
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 10625
diff changeset
   181
 * \param mask the default mask
16bbfc4cb29d [Bug 1862] NS_LOG="Time=*|prefix_time" causes stack overflow
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 10625
diff changeset
   182
 */
16bbfc4cb29d [Bug 1862] NS_LOG="Time=*|prefix_time" causes stack overflow
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 10625
diff changeset
   183
#define NS_LOG_COMPONENT_DEFINE_MASK(name, mask)                \
16bbfc4cb29d [Bug 1862] NS_LOG="Time=*|prefix_time" causes stack overflow
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 10625
diff changeset
   184
  static ns3::LogComponent g_log = ns3::LogComponent (name, mask)
16bbfc4cb29d [Bug 1862] NS_LOG="Time=*|prefix_time" causes stack overflow
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 10625
diff changeset
   185
16bbfc4cb29d [Bug 1862] NS_LOG="Time=*|prefix_time" causes stack overflow
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 10625
diff changeset
   186
/**
16bbfc4cb29d [Bug 1862] NS_LOG="Time=*|prefix_time" causes stack overflow
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 10625
diff changeset
   187
 * \ingroup logging
2980
98b75bde4403 add doxygen.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2979
diff changeset
   188
 *
98b75bde4403 add doxygen.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2979
diff changeset
   189
 * Use \ref NS_LOG to output a message of level LOG_ERROR.
10654
0148f9c47331 [doxygen] Make introspected lists more visible, various other doxy
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 10651
diff changeset
   190
 *
0148f9c47331 [doxygen] Make introspected lists more visible, various other doxy
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 10651
diff changeset
   191
 * \param msg the message to log
2980
98b75bde4403 add doxygen.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2979
diff changeset
   192
 */
98b75bde4403 add doxygen.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2979
diff changeset
   193
#define NS_LOG_ERROR(msg) \
7256
b04ba6772f8c rerun check-style.py at default level to enforce space after function name
Tom Henderson <tomh@tomh.org>
parents: 7252
diff changeset
   194
  NS_LOG (ns3::LOG_ERROR, msg)
2980
98b75bde4403 add doxygen.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2979
diff changeset
   195
98b75bde4403 add doxygen.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2979
diff changeset
   196
/**
98b75bde4403 add doxygen.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2979
diff changeset
   197
 * \ingroup logging
98b75bde4403 add doxygen.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2979
diff changeset
   198
 *
98b75bde4403 add doxygen.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2979
diff changeset
   199
 * Use \ref NS_LOG to output a message of level LOG_WARN.
10654
0148f9c47331 [doxygen] Make introspected lists more visible, various other doxy
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 10651
diff changeset
   200
 *
0148f9c47331 [doxygen] Make introspected lists more visible, various other doxy
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 10651
diff changeset
   201
 * \param msg the message to log
2980
98b75bde4403 add doxygen.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2979
diff changeset
   202
 */
98b75bde4403 add doxygen.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2979
diff changeset
   203
#define NS_LOG_WARN(msg) \
7256
b04ba6772f8c rerun check-style.py at default level to enforce space after function name
Tom Henderson <tomh@tomh.org>
parents: 7252
diff changeset
   204
  NS_LOG (ns3::LOG_WARN, msg)
2980
98b75bde4403 add doxygen.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2979
diff changeset
   205
98b75bde4403 add doxygen.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2979
diff changeset
   206
/**
98b75bde4403 add doxygen.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2979
diff changeset
   207
 * \ingroup logging
98b75bde4403 add doxygen.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2979
diff changeset
   208
 *
98b75bde4403 add doxygen.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2979
diff changeset
   209
 * Use \ref NS_LOG to output a message of level LOG_DEBUG.
10654
0148f9c47331 [doxygen] Make introspected lists more visible, various other doxy
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 10651
diff changeset
   210
 *
0148f9c47331 [doxygen] Make introspected lists more visible, various other doxy
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 10651
diff changeset
   211
 * \param msg the message to log
2980
98b75bde4403 add doxygen.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2979
diff changeset
   212
 */
98b75bde4403 add doxygen.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2979
diff changeset
   213
#define NS_LOG_DEBUG(msg) \
7256
b04ba6772f8c rerun check-style.py at default level to enforce space after function name
Tom Henderson <tomh@tomh.org>
parents: 7252
diff changeset
   214
  NS_LOG (ns3::LOG_DEBUG, msg)
2980
98b75bde4403 add doxygen.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2979
diff changeset
   215
98b75bde4403 add doxygen.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2979
diff changeset
   216
/**
98b75bde4403 add doxygen.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2979
diff changeset
   217
 * \ingroup logging
98b75bde4403 add doxygen.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2979
diff changeset
   218
 *
98b75bde4403 add doxygen.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2979
diff changeset
   219
 * Use \ref NS_LOG to output a message of level LOG_INFO.
10654
0148f9c47331 [doxygen] Make introspected lists more visible, various other doxy
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 10651
diff changeset
   220
 *
0148f9c47331 [doxygen] Make introspected lists more visible, various other doxy
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 10651
diff changeset
   221
 * \param msg the message to log
2980
98b75bde4403 add doxygen.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2979
diff changeset
   222
 */
98b75bde4403 add doxygen.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2979
diff changeset
   223
#define NS_LOG_INFO(msg) \
7256
b04ba6772f8c rerun check-style.py at default level to enforce space after function name
Tom Henderson <tomh@tomh.org>
parents: 7252
diff changeset
   224
  NS_LOG (ns3::LOG_INFO, msg)
2980
98b75bde4403 add doxygen.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2979
diff changeset
   225
98b75bde4403 add doxygen.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2979
diff changeset
   226
/**
98b75bde4403 add doxygen.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2979
diff changeset
   227
 * \ingroup logging
98b75bde4403 add doxygen.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2979
diff changeset
   228
 *
98b75bde4403 add doxygen.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2979
diff changeset
   229
 * Use \ref NS_LOG to output a message of level LOG_LOGIC
10654
0148f9c47331 [doxygen] Make introspected lists more visible, various other doxy
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 10651
diff changeset
   230
 *
0148f9c47331 [doxygen] Make introspected lists more visible, various other doxy
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 10651
diff changeset
   231
 * \param msg the message to log
2980
98b75bde4403 add doxygen.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2979
diff changeset
   232
 */
1503
53dd8f414ba6 sorting out logging
Craig Dowell <craigdo@ee.washington.edu>
parents: 1498
diff changeset
   233
#define NS_LOG_LOGIC(msg) \
7256
b04ba6772f8c rerun check-style.py at default level to enforce space after function name
Tom Henderson <tomh@tomh.org>
parents: 7252
diff changeset
   234
  NS_LOG (ns3::LOG_LOGIC, msg)
1503
53dd8f414ba6 sorting out logging
Craig Dowell <craigdo@ee.washington.edu>
parents: 1498
diff changeset
   235
7017
f288fc1bb2be making NS3_LOGGING_ENABLE control macro expansion and nothing more
Mathieu Lacage <mathieu.lacage@inria.fr>
parents: 6821
diff changeset
   236
1498
520bc8457799 log rides along for free
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   237
namespace ns3 {
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
/**
520bc8457799 log rides along for free
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   240
 * \ingroup logging
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
 * Print the list of logging messages available.
2979
3d39dd617b8d add time logging support
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2978
diff changeset
   243
 * Same as running your program with the NS_LOG environment
3d39dd617b8d add time logging support
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2978
diff changeset
   244
 * variable set as NS_LOG=print-list
1498
520bc8457799 log rides along for free
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   245
 */
520bc8457799 log rides along for free
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   246
void LogComponentPrintList (void);
520bc8457799 log rides along for free
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   247
7169
358f71a624d8 core coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents: 7017
diff changeset
   248
typedef void (*LogTimePrinter)(std::ostream &os);
358f71a624d8 core coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents: 7017
diff changeset
   249
typedef void (*LogNodePrinter)(std::ostream &os);
2979
3d39dd617b8d add time logging support
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2978
diff changeset
   250
3005
cc521f35f033 avoid segfault when setting NS_LOG=*
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2986
diff changeset
   251
void LogSetTimePrinter (LogTimePrinter);
7256
b04ba6772f8c rerun check-style.py at default level to enforce space after function name
Tom Henderson <tomh@tomh.org>
parents: 7252
diff changeset
   252
LogTimePrinter LogGetTimePrinter (void);
2979
3d39dd617b8d add time logging support
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2978
diff changeset
   253
5522
0d1a06c5b285 Print node context in log messages
Guillaume Seguin <guillaume@segu.in>
parents: 4353
diff changeset
   254
void LogSetNodePrinter (LogNodePrinter);
7256
b04ba6772f8c rerun check-style.py at default level to enforce space after function name
Tom Henderson <tomh@tomh.org>
parents: 7252
diff changeset
   255
LogNodePrinter LogGetNodePrinter (void);
5522
0d1a06c5b285 Print node context in log messages
Guillaume Seguin <guillaume@segu.in>
parents: 4353
diff changeset
   256
2979
3d39dd617b8d add time logging support
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2978
diff changeset
   257
10626
16bbfc4cb29d [Bug 1862] NS_LOG="Time=*|prefix_time" causes stack overflow
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 10625
diff changeset
   258
/**
16bbfc4cb29d [Bug 1862] NS_LOG="Time=*|prefix_time" causes stack overflow
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 10625
diff changeset
   259
 * \ingroup logging
16bbfc4cb29d [Bug 1862] NS_LOG="Time=*|prefix_time" causes stack overflow
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 10625
diff changeset
   260
 *
16bbfc4cb29d [Bug 1862] NS_LOG="Time=*|prefix_time" causes stack overflow
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 10625
diff changeset
   261
 * A single log component configuration.
16bbfc4cb29d [Bug 1862] NS_LOG="Time=*|prefix_time" causes stack overflow
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 10625
diff changeset
   262
 */
16bbfc4cb29d [Bug 1862] NS_LOG="Time=*|prefix_time" causes stack overflow
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 10625
diff changeset
   263
class LogComponent
16bbfc4cb29d [Bug 1862] NS_LOG="Time=*|prefix_time" causes stack overflow
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 10625
diff changeset
   264
{
1498
520bc8457799 log rides along for free
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   265
public:
10626
16bbfc4cb29d [Bug 1862] NS_LOG="Time=*|prefix_time" causes stack overflow
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 10625
diff changeset
   266
  /**
16bbfc4cb29d [Bug 1862] NS_LOG="Time=*|prefix_time" causes stack overflow
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 10625
diff changeset
   267
   * Constructor
16bbfc4cb29d [Bug 1862] NS_LOG="Time=*|prefix_time" causes stack overflow
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 10625
diff changeset
   268
   *
16bbfc4cb29d [Bug 1862] NS_LOG="Time=*|prefix_time" causes stack overflow
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 10625
diff changeset
   269
   * \param [in] name the user-visible name for this component.
10654
0148f9c47331 [doxygen] Make introspected lists more visible, various other doxy
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 10651
diff changeset
   270
   * \param [in] mask LogLevels blocked for this LogComponent.  Blocking
0148f9c47331 [doxygen] Make introspected lists more visible, various other doxy
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 10651
diff changeset
   271
   *                  a log level helps prevent recursion by logging in
0148f9c47331 [doxygen] Make introspected lists more visible, various other doxy
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 10651
diff changeset
   272
   *                  functions which help implement the logging facility.
10626
16bbfc4cb29d [Bug 1862] NS_LOG="Time=*|prefix_time" causes stack overflow
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 10625
diff changeset
   273
   */
16bbfc4cb29d [Bug 1862] NS_LOG="Time=*|prefix_time" causes stack overflow
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 10625
diff changeset
   274
  LogComponent (const std::string & name, const enum LogLevel mask = LOG_NONE);
16bbfc4cb29d [Bug 1862] NS_LOG="Time=*|prefix_time" causes stack overflow
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 10625
diff changeset
   275
  /**
16bbfc4cb29d [Bug 1862] NS_LOG="Time=*|prefix_time" causes stack overflow
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 10625
diff changeset
   276
   * Check if this LogComponent is enabled for \pname{level}
16bbfc4cb29d [Bug 1862] NS_LOG="Time=*|prefix_time" causes stack overflow
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 10625
diff changeset
   277
   *
16bbfc4cb29d [Bug 1862] NS_LOG="Time=*|prefix_time" causes stack overflow
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 10625
diff changeset
   278
   * \param [in] level the level to check for.
16bbfc4cb29d [Bug 1862] NS_LOG="Time=*|prefix_time" causes stack overflow
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 10625
diff changeset
   279
   * \return true if \pname{level} is enabled.
16bbfc4cb29d [Bug 1862] NS_LOG="Time=*|prefix_time" causes stack overflow
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 10625
diff changeset
   280
   */
16bbfc4cb29d [Bug 1862] NS_LOG="Time=*|prefix_time" causes stack overflow
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 10625
diff changeset
   281
  bool IsEnabled (const enum LogLevel level) const;
16bbfc4cb29d [Bug 1862] NS_LOG="Time=*|prefix_time" causes stack overflow
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 10625
diff changeset
   282
  /**
16bbfc4cb29d [Bug 1862] NS_LOG="Time=*|prefix_time" causes stack overflow
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 10625
diff changeset
   283
   * Check if all levels are disabled.
16bbfc4cb29d [Bug 1862] NS_LOG="Time=*|prefix_time" causes stack overflow
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 10625
diff changeset
   284
   *
16bbfc4cb29d [Bug 1862] NS_LOG="Time=*|prefix_time" causes stack overflow
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 10625
diff changeset
   285
   * \return true if all levels are disabled.
16bbfc4cb29d [Bug 1862] NS_LOG="Time=*|prefix_time" causes stack overflow
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 10625
diff changeset
   286
   */
1498
520bc8457799 log rides along for free
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   287
  bool IsNoneEnabled (void) const;
10626
16bbfc4cb29d [Bug 1862] NS_LOG="Time=*|prefix_time" causes stack overflow
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 10625
diff changeset
   288
  /**
16bbfc4cb29d [Bug 1862] NS_LOG="Time=*|prefix_time" causes stack overflow
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 10625
diff changeset
   289
   * Enable this LogComponent at \pname{level}
16bbfc4cb29d [Bug 1862] NS_LOG="Time=*|prefix_time" causes stack overflow
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 10625
diff changeset
   290
   *
16bbfc4cb29d [Bug 1862] NS_LOG="Time=*|prefix_time" causes stack overflow
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 10625
diff changeset
   291
   * \param [in] level the LogLevel to enable.
16bbfc4cb29d [Bug 1862] NS_LOG="Time=*|prefix_time" causes stack overflow
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 10625
diff changeset
   292
   */
16bbfc4cb29d [Bug 1862] NS_LOG="Time=*|prefix_time" causes stack overflow
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 10625
diff changeset
   293
  void Enable (const enum LogLevel level);
16bbfc4cb29d [Bug 1862] NS_LOG="Time=*|prefix_time" causes stack overflow
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 10625
diff changeset
   294
  /**
16bbfc4cb29d [Bug 1862] NS_LOG="Time=*|prefix_time" causes stack overflow
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 10625
diff changeset
   295
   * Disable logging at \pname{level} for this LogComponent.
16bbfc4cb29d [Bug 1862] NS_LOG="Time=*|prefix_time" causes stack overflow
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 10625
diff changeset
   296
   *
16bbfc4cb29d [Bug 1862] NS_LOG="Time=*|prefix_time" causes stack overflow
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 10625
diff changeset
   297
   * \param [in] level the LogLevel to disable.
16bbfc4cb29d [Bug 1862] NS_LOG="Time=*|prefix_time" causes stack overflow
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 10625
diff changeset
   298
   */
16bbfc4cb29d [Bug 1862] NS_LOG="Time=*|prefix_time" causes stack overflow
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 10625
diff changeset
   299
  void Disable (const enum LogLevel level);
16bbfc4cb29d [Bug 1862] NS_LOG="Time=*|prefix_time" causes stack overflow
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 10625
diff changeset
   300
  /**
16bbfc4cb29d [Bug 1862] NS_LOG="Time=*|prefix_time" causes stack overflow
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 10625
diff changeset
   301
   * Get the name of this LogComponent.
16bbfc4cb29d [Bug 1862] NS_LOG="Time=*|prefix_time" causes stack overflow
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 10625
diff changeset
   302
   *
16bbfc4cb29d [Bug 1862] NS_LOG="Time=*|prefix_time" causes stack overflow
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 10625
diff changeset
   303
   * \return the name of this LogComponent.
16bbfc4cb29d [Bug 1862] NS_LOG="Time=*|prefix_time" causes stack overflow
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 10625
diff changeset
   304
   */
1772
dd278e20e52e log verbosity changes
Craig Dowell <craigdo@ee.washington.edu>
parents: 1507
diff changeset
   305
  char const *Name (void) const;
10626
16bbfc4cb29d [Bug 1862] NS_LOG="Time=*|prefix_time" causes stack overflow
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 10625
diff changeset
   306
  /**
16bbfc4cb29d [Bug 1862] NS_LOG="Time=*|prefix_time" causes stack overflow
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 10625
diff changeset
   307
   * Get the string label for the given LogLevel.
16bbfc4cb29d [Bug 1862] NS_LOG="Time=*|prefix_time" causes stack overflow
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 10625
diff changeset
   308
   *
16bbfc4cb29d [Bug 1862] NS_LOG="Time=*|prefix_time" causes stack overflow
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 10625
diff changeset
   309
   * \param [in] level the LogLevel to get the label for.
16bbfc4cb29d [Bug 1862] NS_LOG="Time=*|prefix_time" causes stack overflow
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 10625
diff changeset
   310
   * \return the string label for \pname{level}
16bbfc4cb29d [Bug 1862] NS_LOG="Time=*|prefix_time" causes stack overflow
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 10625
diff changeset
   311
   */
16bbfc4cb29d [Bug 1862] NS_LOG="Time=*|prefix_time" causes stack overflow
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 10625
diff changeset
   312
  static std::string GetLevelLabel(const enum LogLevel level);
16bbfc4cb29d [Bug 1862] NS_LOG="Time=*|prefix_time" causes stack overflow
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 10625
diff changeset
   313
  /**
16bbfc4cb29d [Bug 1862] NS_LOG="Time=*|prefix_time" causes stack overflow
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 10625
diff changeset
   314
   * Prevent the enabling of a specific LogLevel.
16bbfc4cb29d [Bug 1862] NS_LOG="Time=*|prefix_time" causes stack overflow
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 10625
diff changeset
   315
   *
16bbfc4cb29d [Bug 1862] NS_LOG="Time=*|prefix_time" causes stack overflow
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 10625
diff changeset
   316
   * \param level the LogLevel to block
16bbfc4cb29d [Bug 1862] NS_LOG="Time=*|prefix_time" causes stack overflow
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 10625
diff changeset
   317
   */
16bbfc4cb29d [Bug 1862] NS_LOG="Time=*|prefix_time" causes stack overflow
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 10625
diff changeset
   318
  void SetMask (const enum LogLevel level);
1498
520bc8457799 log rides along for free
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   319
private:
10626
16bbfc4cb29d [Bug 1862] NS_LOG="Time=*|prefix_time" causes stack overflow
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 10625
diff changeset
   320
  /**
16bbfc4cb29d [Bug 1862] NS_LOG="Time=*|prefix_time" causes stack overflow
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 10625
diff changeset
   321
   * Parse the `NS_LOG` environment variable for options relating to this
16bbfc4cb29d [Bug 1862] NS_LOG="Time=*|prefix_time" causes stack overflow
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 10625
diff changeset
   322
   * LogComponent.
16bbfc4cb29d [Bug 1862] NS_LOG="Time=*|prefix_time" causes stack overflow
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 10625
diff changeset
   323
   */
16bbfc4cb29d [Bug 1862] NS_LOG="Time=*|prefix_time" causes stack overflow
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 10625
diff changeset
   324
  void EnvVarCheck (void);
10625
c3e9a5530654 [Bug 1792] [Bug 1853] Remove inheritance from std::stream in ParameterLogger
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 10516
diff changeset
   325
  
10626
16bbfc4cb29d [Bug 1862] NS_LOG="Time=*|prefix_time" causes stack overflow
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 10625
diff changeset
   326
  int32_t     m_levels;  //!< Enabled LogLevels
16bbfc4cb29d [Bug 1862] NS_LOG="Time=*|prefix_time" causes stack overflow
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 10625
diff changeset
   327
  int32_t     m_mask;    //!< Blocked LogLevels
16bbfc4cb29d [Bug 1862] NS_LOG="Time=*|prefix_time" causes stack overflow
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 10625
diff changeset
   328
  std::string m_name;    //!< LogComponent name
16bbfc4cb29d [Bug 1862] NS_LOG="Time=*|prefix_time" causes stack overflow
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 10625
diff changeset
   329
16bbfc4cb29d [Bug 1862] NS_LOG="Time=*|prefix_time" causes stack overflow
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 10625
diff changeset
   330
};  // class LogComponent
1498
520bc8457799 log rides along for free
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   331
10625
c3e9a5530654 [Bug 1792] [Bug 1853] Remove inheritance from std::stream in ParameterLogger
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 10516
diff changeset
   332
/**
c3e9a5530654 [Bug 1792] [Bug 1853] Remove inheritance from std::stream in ParameterLogger
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 10516
diff changeset
   333
 * \ingroup logging
c3e9a5530654 [Bug 1792] [Bug 1853] Remove inheritance from std::stream in ParameterLogger
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 10516
diff changeset
   334
 *
10654
0148f9c47331 [doxygen] Make introspected lists more visible, various other doxy
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 10651
diff changeset
   335
 * Insert `, ` when streaming function arguments.
10625
c3e9a5530654 [Bug 1792] [Bug 1853] Remove inheritance from std::stream in ParameterLogger
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 10516
diff changeset
   336
 */
c3e9a5530654 [Bug 1792] [Bug 1853] Remove inheritance from std::stream in ParameterLogger
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 10516
diff changeset
   337
class ParameterLogger
2978
c93e1d0d6916 cleanup to avoid too many #ifdefs
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2976
diff changeset
   338
{
10654
0148f9c47331 [doxygen] Make introspected lists more visible, various other doxy
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 10651
diff changeset
   339
  bool m_first;        //!< First argument flag, doesn't get `, `.
10625
c3e9a5530654 [Bug 1792] [Bug 1853] Remove inheritance from std::stream in ParameterLogger
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 10516
diff changeset
   340
  std::ostream &m_os;  //!< Underlying output stream.
2978
c93e1d0d6916 cleanup to avoid too many #ifdefs
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2976
diff changeset
   341
public:
10625
c3e9a5530654 [Bug 1792] [Bug 1853] Remove inheritance from std::stream in ParameterLogger
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 10516
diff changeset
   342
  /**
c3e9a5530654 [Bug 1792] [Bug 1853] Remove inheritance from std::stream in ParameterLogger
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 10516
diff changeset
   343
   * Constructor.
c3e9a5530654 [Bug 1792] [Bug 1853] Remove inheritance from std::stream in ParameterLogger
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 10516
diff changeset
   344
   *
c3e9a5530654 [Bug 1792] [Bug 1853] Remove inheritance from std::stream in ParameterLogger
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 10516
diff changeset
   345
   * \param [in] os Underlying output stream.
c3e9a5530654 [Bug 1792] [Bug 1853] Remove inheritance from std::stream in ParameterLogger
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 10516
diff changeset
   346
   */
2979
3d39dd617b8d add time logging support
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2978
diff changeset
   347
  ParameterLogger (std::ostream &os);
2978
c93e1d0d6916 cleanup to avoid too many #ifdefs
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2976
diff changeset
   348
10625
c3e9a5530654 [Bug 1792] [Bug 1853] Remove inheritance from std::stream in ParameterLogger
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 10516
diff changeset
   349
  /**
c3e9a5530654 [Bug 1792] [Bug 1853] Remove inheritance from std::stream in ParameterLogger
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 10516
diff changeset
   350
   * Write a function parameter on the output stream,
10654
0148f9c47331 [doxygen] Make introspected lists more visible, various other doxy
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 10651
diff changeset
   351
   * separating paramters after the first by `,` strings.
10625
c3e9a5530654 [Bug 1792] [Bug 1853] Remove inheritance from std::stream in ParameterLogger
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 10516
diff changeset
   352
   *
c3e9a5530654 [Bug 1792] [Bug 1853] Remove inheritance from std::stream in ParameterLogger
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 10516
diff changeset
   353
   * \param [in] param the function parameter
c3e9a5530654 [Bug 1792] [Bug 1853] Remove inheritance from std::stream in ParameterLogger
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 10516
diff changeset
   354
   */
2978
c93e1d0d6916 cleanup to avoid too many #ifdefs
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2976
diff changeset
   355
  template<typename T>
c93e1d0d6916 cleanup to avoid too many #ifdefs
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2976
diff changeset
   356
  ParameterLogger& operator<< (T param)
c93e1d0d6916 cleanup to avoid too many #ifdefs
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2976
diff changeset
   357
  {
10625
c3e9a5530654 [Bug 1792] [Bug 1853] Remove inheritance from std::stream in ParameterLogger
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 10516
diff changeset
   358
    if (m_first)
2978
c93e1d0d6916 cleanup to avoid too many #ifdefs
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2976
diff changeset
   359
      {
2979
3d39dd617b8d add time logging support
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2978
diff changeset
   360
        m_os << param;
10625
c3e9a5530654 [Bug 1792] [Bug 1853] Remove inheritance from std::stream in ParameterLogger
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 10516
diff changeset
   361
        m_first = false;
c3e9a5530654 [Bug 1792] [Bug 1853] Remove inheritance from std::stream in ParameterLogger
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 10516
diff changeset
   362
      }
c3e9a5530654 [Bug 1792] [Bug 1853] Remove inheritance from std::stream in ParameterLogger
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 10516
diff changeset
   363
    else
c3e9a5530654 [Bug 1792] [Bug 1853] Remove inheritance from std::stream in ParameterLogger
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 10516
diff changeset
   364
      {
2979
3d39dd617b8d add time logging support
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2978
diff changeset
   365
        m_os << ", " << param;
2978
c93e1d0d6916 cleanup to avoid too many #ifdefs
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2976
diff changeset
   366
      }
c93e1d0d6916 cleanup to avoid too many #ifdefs
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2976
diff changeset
   367
    return *this;
c93e1d0d6916 cleanup to avoid too many #ifdefs
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2976
diff changeset
   368
  }
c93e1d0d6916 cleanup to avoid too many #ifdefs
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2976
diff changeset
   369
};
c93e1d0d6916 cleanup to avoid too many #ifdefs
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2976
diff changeset
   370
1498
520bc8457799 log rides along for free
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   371
} // namespace ns3
520bc8457799 log rides along for free
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   372
2978
c93e1d0d6916 cleanup to avoid too many #ifdefs
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2976
diff changeset
   373
9184
065a297f6c9d bug 1531: Crash when using NS_LOG in destructors of static objects
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 9119
diff changeset
   374
#endif /* NS3_LOG_H */