This file is indexed.

/usr/include/ns3.26/ns3/log.h is in libns3-dev 3.26+dfsg-1.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
 * Copyright (c) 2006,2007 INRIA
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License version 2 as
 * published by the Free Software Foundation;
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 *
 * Author: Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
 */

#ifndef NS3_LOG_H
#define NS3_LOG_H

#include <string>
#include <iostream>
#include <stdint.h>
#include <map>

#include "log-macros-enabled.h"
#include "log-macros-disabled.h"

/**
 * \file
 * \ingroup logging
 * Debug message logging
 */

/**
 * \ingroup debugging
 * \defgroup logging Logging
 *
 * \brief Logging functions and macros
 *
 * LOG functionality: macros which allow developers to
 * send information to the \c std::clog output stream.
 *
 * All logging messages are disabled by default. To enable selected logging 
 * messages, use the ns3::LogComponentEnable
 * function or use the NS_LOG environment variable 
 *
 * Use the environment variable NS_LOG to define a ':'-separated list of
 * logging components to enable. For example (using bash syntax),
 * \code
 *   $ NS_LOG="OlsrAgent" ./waf --run ...
 * \endcode
 * would enable one component at all log levels.
 * \code
 *   $NS_LOG="OlsrAgent:Ipv4L3Protocol" ./waf --run ...
 * \endcode
 * would enable two components, at all log levels, etc.
 * \c NS_LOG="*" will enable all available log components at all levels.
 *
 * To control more selectively the log levels for each component, use
 * this syntax:
 * \code
 *   $ NS_LOG='Component1=func|warn:Component2=error|debug'
 * \endcode
 * This example would enable the \c func, and \c warn log
 * levels for 'Component1' and the \c error and \c debug log levels
 * for 'Component2'.  The wildcard '*' can be used here as well.  For example
 * \c NS_LOG='*=level_all|prefix' would enable all log levels and prefix all
 * prints with the component and function names.
 *
 * A note on NS_LOG_FUNCTION() and NS_LOG_FUNCTION_NOARGS():
 * generally, use of (at least) NS_LOG_FUNCTION(this) is preferred,
 * with the any function parameters added:
 * \code
 *   NS_LOG_FUNCTION (this << arg1 << args);
 * \endcode
 * Use NS_LOG_FUNCTION_NOARGS() only in static functions with no arguments.
 */
/** @{ */


namespace ns3 {

/**
 *  Logging severity classes and levels.
 */
enum LogLevel {
  LOG_NONE           = 0x00000000, //!< No logging.

  LOG_ERROR          = 0x00000001, //!< Serious error messages only.
  LOG_LEVEL_ERROR    = 0x00000001, //!< LOG_ERROR and above.

  LOG_WARN           = 0x00000002, //!< Warning messages.
  LOG_LEVEL_WARN     = 0x00000003, //!< LOG_WARN and above.

  LOG_DEBUG          = 0x00000004, //!< Rare ad-hoc debug messages.
  LOG_LEVEL_DEBUG    = 0x00000007, //!< LOG_DEBUG and above.

  LOG_INFO           = 0x00000008, //!< Informational messages (e.g., banners).
  LOG_LEVEL_INFO     = 0x0000000f, //!< LOG_INFO and above.

  LOG_FUNCTION       = 0x00000010, //!< Function tracing.
  LOG_LEVEL_FUNCTION = 0x0000001f, //!< LOG_FUNCTION and above.

  LOG_LOGIC          = 0x00000020, //!< Control flow tracing within functions.
  LOG_LEVEL_LOGIC    = 0x0000003f, //!< LOG_LOGIC and above.

  LOG_ALL            = 0x0fffffff, //!< Print everything.
  LOG_LEVEL_ALL      = LOG_ALL,    //!< Print everything.

  LOG_PREFIX_FUNC    = 0x80000000, //!< Prefix all trace prints with function.
  LOG_PREFIX_TIME    = 0x40000000, //!< Prefix all trace prints with simulation time.
  LOG_PREFIX_NODE    = 0x20000000, //!< Prefix all trace prints with simulation node.
  LOG_PREFIX_LEVEL   = 0x10000000, //!< Prefix all trace prints with log level (severity).
  LOG_PREFIX_ALL     = 0xf0000000  //!< All prefixes.
};

/**
 * Enable the logging output associated with that log component.
 *
 * The logging output can be later disabled with a call
 * to ns3::LogComponentDisable.
 *
 * Same as running your program with the NS_LOG environment
 * variable set as NS_LOG='name=level'.
 *
 * \param [in] name The log component name.
 * \param [in] level The logging level.
 */
void LogComponentEnable (char const *name, enum LogLevel level);

/**
 * Enable the logging output for all registered log components.
 *
 * Same as running your program with the NS_LOG environment
 * variable set as NS_LOG='*=level'
 *
 * \param [in] level The logging level.
 */
void LogComponentEnableAll (enum LogLevel level);


/**
 * Disable the logging output associated with that log component.
 *
 * The logging output can be later re-enabled with a call
 * to LogComponentEnable.
 *
 * \param [in] name The log component name.
 * \param [in] level The logging level.
 */
void LogComponentDisable (char const *name, enum LogLevel level);

/**
 * Disable all logging for all components.
 *
 * \param [in] level The logging level.
 */
void LogComponentDisableAll (enum LogLevel level);


} // namespace ns3


/**
 * Define a Log component with a specific name.
 *
 * This macro should be used at the top of every file in which you want 
 * to use the NS_LOG macro. This macro defines a new
 * "log component" which can be later selectively enabled
 * or disabled with the ns3::LogComponentEnable and 
 * ns3::LogComponentDisable functions or with the NS_LOG
 * environment variable.
 *
 * LogComponent names should be simple string tokens, _i.e._,
 * "ArfWifiManager", not "ns3::ArfWifiManager".
 *
 * This macro should be placed within namespace ns3.  If functions
 * outside of namespace ns3 require access to logging, the preferred
 * solution is to add the following 'using' directive at file scope,
 * outside of namespace ns3, and after the inclusion of
 * NS_LOG_COMPONENT_DEFINE, such as follows:
 * \code
 *   namespace ns3 {
 *     NS_LOG_COMPONENT_DEFINE ("...");
 *
 *     // Definitions within the ns3 namespace
 *
 *   } // namespace ns3
 *
 *   using ns3::g_log;
 *
 *   // Further definitions outside of the ns3 namespace
 *\endcode
 *
 * \param [in] name The log component name.
 */
#define NS_LOG_COMPONENT_DEFINE(name)                           \
  static ns3::LogComponent g_log = ns3::LogComponent (name, __FILE__)

/**
 * Define a logging component with a mask.
 *
 * See LogComponent().
 *
 * \param [in] name The log component name.
 * \param [in] mask The default mask.
 */
#define NS_LOG_COMPONENT_DEFINE_MASK(name, mask)                \
  static ns3::LogComponent g_log = ns3::LogComponent (name, __FILE__, mask)

/**
 * Use \ref NS_LOG to output a message of level LOG_ERROR.
 *
 * \param [in] msg The message to log.
 */
#define NS_LOG_ERROR(msg) \
  NS_LOG (ns3::LOG_ERROR, msg)

/**
 * Use \ref NS_LOG to output a message of level LOG_WARN.
 *
 * \param [in] msg The message to log.
 */
#define NS_LOG_WARN(msg) \
  NS_LOG (ns3::LOG_WARN, msg)

/**
 * Use \ref NS_LOG to output a message of level LOG_DEBUG.
 *
 * \param [in] msg The message to log.
 */
#define NS_LOG_DEBUG(msg) \
  NS_LOG (ns3::LOG_DEBUG, msg)

/**
 * Use \ref NS_LOG to output a message of level LOG_INFO.
 *
 * \param [in] msg The message to log.
 */
#define NS_LOG_INFO(msg) \
  NS_LOG (ns3::LOG_INFO, msg)

/**
 * Use \ref NS_LOG to output a message of level LOG_LOGIC
 *
 * \param [in] msg The message to log.
 */
#define NS_LOG_LOGIC(msg) \
  NS_LOG (ns3::LOG_LOGIC, msg)


namespace ns3 {

/**
 * Print the list of logging messages available.
 * Same as running your program with the NS_LOG environment
 * variable set as NS_LOG=print-list
 */
void LogComponentPrintList (void);

/**
 * Function signature for prepending the simulation time
 * to a log message.
 *
 * \param [in,out] os The output stream to print on.
 */
typedef void (*LogTimePrinter)(std::ostream &os);
/**
 * Function signature for prepending the node id
 * to a log message.
 *
 * \param [in,out] os The output stream to print on.
 */
typedef void (*LogNodePrinter)(std::ostream &os);

/**
 * Set the LogTimePrinter function to be used
 * to prepend log messages with the simulation time.
 *
 * \param [in] lp The LogTimePrinter function.
 */
void LogSetTimePrinter (LogTimePrinter lp);
/**
 * Get the LogTimePrinter function currently in use.
 * \returns The LogTimePrinter function.
 */
LogTimePrinter LogGetTimePrinter (void);

/**
 * Set the LogNodePrinter function to be used
 * to prepend log messages with the node id.
 *
 * \param [in] np The LogNodePrinter function.
 */
void LogSetNodePrinter (LogNodePrinter np);
/**
 * Get the LogNodePrinter function currently in use.
 * \returns The LogNodePrinter function.
 */
LogNodePrinter LogGetNodePrinter (void);


/**
 * A single log component configuration.
 */
class LogComponent
{
public:
  /**
   * Constructor.
   *
   * \param [in] name The user-visible name for this component.
   * \param [in] file The source code file which defined this LogComponent.
   * \param [in] mask LogLevels blocked for this LogComponent.  Blocking
   *                  a log level helps prevent recursion by logging in
   *                  functions which help implement the logging facility.
   */
  LogComponent (const std::string & name,
                const std::string & file,
                const enum LogLevel mask = LOG_NONE);
  /**
   * Check if this LogComponent is enabled for \c level
   *
   * \param [in] level The level to check for.
   * \return \c true if we are enabled at \c level.
   */
  bool IsEnabled (const enum LogLevel level) const;
  /**
   * Check if all levels are disabled.
   *
   * \return \c true if all levels are disabled.
   */
  bool IsNoneEnabled (void) const;
  /**
   * Enable this LogComponent at \c level
   *
   * \param [in] level The LogLevel to enable.
   */
  void Enable (const enum LogLevel level);
  /**
   * Disable logging at \c level for this LogComponent.
   *
   * \param [in] level The LogLevel to disable.
   */
  void Disable (const enum LogLevel level);
  /**
   * Get the name of this LogComponent.
   *
   * \return The name of this LogComponent.
   */
  char const *Name (void) const;
  /**
   * Get the compilation unit defining this LogComponent.
   * \returns The file name.
   */
  std::string File (void) const;
  /**
   * Get the string label for the given LogLevel.
   *
   * \param [in] level The LogLevel to get the label for.
   * \return The string label for \c level.
   */
  static std::string GetLevelLabel(const enum LogLevel level);
  /**
   * Prevent the enabling of a specific LogLevel.
   *
   * \param [in] level The LogLevel to block.
   */
  void SetMask (const enum LogLevel level);

  /**
   * LogComponent name map.
   *
   * \internal
   * This should really be considered an internal API.
   * It is exposed here to allow print-introspected-doxygen.cc
   * to generate a list of all LogComponents.
   */
  typedef std::map<std::string, LogComponent *> ComponentList;

  /**
   * Get the list of LogComponnents.
   *
   * \internal
   * This should really be considered an internal API.
   * It is exposed here to allow print-introspected-doxygen.cc
   * to generate a list of all LogComponents.
   *
   * \returns The list of LogComponents.
   */
  static ComponentList *GetComponentList (void);

  
private:
  /**
   * Parse the `NS_LOG` environment variable for options relating to this
   * LogComponent.
   */
  void EnvVarCheck (void);
  
  int32_t     m_levels;  //!< Enabled LogLevels.
  int32_t     m_mask;    //!< Blocked LogLevels.
  std::string m_name;    //!< LogComponent name.
  std::string m_file;    //!< File defining this LogComponent.

};  // class LogComponent

  
/**
 * Insert `, ` when streaming function arguments.
 */
class ParameterLogger
{
  bool m_first;        //!< First argument flag, doesn't get `, `.
  std::ostream &m_os;  //!< Underlying output stream.
public:
  /**
   * Constructor.
   *
   * \param [in] os Underlying output stream.
   */
  ParameterLogger (std::ostream &os);

  /**
   * Write a function parameter on the output stream,
   * separating parameters after the first by `,` strings.
   *
   * \param [in] param The function parameter.
   * \return This ParameterLogger, so it's chainable.
   */
  template<typename T>
  ParameterLogger& operator<< (T param);

};

template<typename T>
ParameterLogger&
ParameterLogger::operator<< (T param)
{
  if (m_first)
    {
      m_os << param;
      m_first = false;
    }
  else
    {
      m_os << ", " << param;
    }
  return *this;
}

/**
 * Specialization for strings.
 * \param [in] param The function parameter.
 * \return This ParameterLogger, so it's chainable.
 */
template<>
ParameterLogger&
ParameterLogger::operator<< <std::string>(const std::string param);
  
/**
 * Specialization for C-strings.
 * \param [in] param The function parameter.
 * \return This ParameterLogger, so it's chainable.
 */
template<>
ParameterLogger&
ParameterLogger::operator<< <const char *>(const char * param);
  
} // namespace ns3

/**@}*/  // \ingroup logging

#endif /* NS3_LOG_H */