A Discrete-Event Network Simulator
API
Loading...
Searching...
No Matches
ns3::LogComponent Class Reference

A single log component configuration. More...

#include "log.h"

+ Collaboration diagram for ns3::LogComponent:

Public Types

using ComponentList = std::unordered_map< std::string, LogComponent * >
 LogComponent name map.
 

Public Member Functions

 LogComponent (const std::string &name, const std::string &file, const LogLevel mask=LOG_NONE)
 Constructor.
 
void Disable (const LogLevel level)
 Disable logging at level for this LogComponent.
 
void Enable (const LogLevel level)
 Enable this LogComponent at level.
 
std::string File () const
 Get the compilation unit defining this LogComponent.
 
bool IsEnabled (const LogLevel level) const
 Check if this LogComponent is enabled for level.
 
bool IsNoneEnabled () const
 Check if all levels are disabled.
 
std::string Name () const
 Get the name of this LogComponent.
 
void SetMask (const LogLevel level)
 Prevent the enabling of a specific LogLevel.
 

Static Public Member Functions

static ComponentListGetComponentList ()
 Get the list of LogComponents.
 
static std::string GetLevelLabel (const LogLevel level)
 Get the string label for the given LogLevel.
 

Private Member Functions

void EnvVarCheck ()
 Parse the NS_LOG environment variable for options relating to this LogComponent.
 

Private Attributes

std::string m_file
 File defining this LogComponent.
 
int32_t m_levels
 Enabled LogLevels.
 
int32_t m_mask
 Blocked LogLevels.
 
std::string m_name
 LogComponent name.
 

Detailed Description

A single log component configuration.

Definition at line 327 of file log.h.

Member Typedef Documentation

◆ ComponentList

using ns3::LogComponent::ComponentList = std::unordered_map<std::string, LogComponent*>

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.

Definition at line 398 of file log.h.

Constructor & Destructor Documentation

◆ LogComponent()

ns3::LogComponent::LogComponent ( const std::string &  name,
const std::string &  file,
const LogLevel  mask = LOG_NONE 
)

Constructor.

Parameters
[in]nameThe user-visible name for this component.
[in]fileThe source code file which defined this LogComponent.
[in]maskLogLevels blocked for this LogComponent. Blocking a log level helps prevent recursion by logging in functions which help implement the logging facility.

Definition at line 159 of file log.cc.

References EnvVarCheck(), GetComponentList(), and NS_FATAL_ERROR.

+ Here is the call graph for this function:

Member Function Documentation

◆ Disable()

void ns3::LogComponent::Disable ( const LogLevel  level)

Disable logging at level for this LogComponent.

Parameters
[in]levelThe LogLevel to disable.

Definition at line 272 of file log.cc.

References m_levels.

◆ Enable()

void ns3::LogComponent::Enable ( const LogLevel  level)

Enable this LogComponent at level.

Parameters
[in]levelThe LogLevel to enable.

Definition at line 266 of file log.cc.

References m_levels.

Referenced by EnvVarCheck().

+ Here is the caller graph for this function:

◆ EnvVarCheck()

void ns3::LogComponent::EnvVarCheck ( )
private

Parse the NS_LOG environment variable for options relating to this LogComponent.

Definition at line 198 of file log.cc.

References Enable(), ns3::EnvironmentVariable::Get(), ns3::LOG_LEVEL_ALL, ns3::LOG_PREFIX_ALL, m_name, NS_ASSERT_MSG, and ns3::SplitString().

Referenced by LogComponent().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ File()

std::string ns3::LogComponent::File ( ) const

Get the compilation unit defining this LogComponent.

Returns
The file name.

Definition at line 284 of file log.cc.

References m_file.

◆ GetComponentList()

LogComponent::ComponentList * ns3::LogComponent::GetComponentList ( )
static

Get the list of LogComponents.

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.

Definition at line 143 of file log.cc.

Referenced by LogComponent(), ns3::ComponentExists(), ns3::GetLogComponent(), ns3::LogComponentDisable(), ns3::LogComponentDisableAll(), ns3::LogComponentEnable(), ns3::LogComponentEnableAll(), ns3::LogComponentPrintList(), and PrintAllLogComponents().

+ Here is the caller graph for this function:

◆ GetLevelLabel()

std::string ns3::LogComponent::GetLevelLabel ( const LogLevel  level)
static

Get the string label for the given LogLevel.

Parameters
[in]levelThe LogLevel to get the label for.
Returns
The string label for level.

Definition at line 291 of file log.cc.

◆ IsEnabled()

bool ns3::LogComponent::IsEnabled ( const LogLevel  level) const

Check if this LogComponent is enabled for level.

Parameters
[in]levelThe level to check for.
Returns
true if we are enabled at level.

Definition at line 247 of file log.cc.

References m_levels.

◆ IsNoneEnabled()

bool ns3::LogComponent::IsNoneEnabled ( ) const

Check if all levels are disabled.

Returns
true if all levels are disabled.

Definition at line 254 of file log.cc.

References m_levels.

◆ Name()

std::string ns3::LogComponent::Name ( ) const

Get the name of this LogComponent.

Returns
The name of this LogComponent.

Definition at line 278 of file log.cc.

References m_name.

◆ SetMask()

void ns3::LogComponent::SetMask ( const LogLevel  level)

Prevent the enabling of a specific LogLevel.

Parameters
[in]levelThe LogLevel to block.

Definition at line 260 of file log.cc.

References m_mask.

Member Data Documentation

◆ m_file

std::string ns3::LogComponent::m_file
private

File defining this LogComponent.

Definition at line 422 of file log.h.

Referenced by File().

◆ m_levels

int32_t ns3::LogComponent::m_levels
private

Enabled LogLevels.

Definition at line 419 of file log.h.

Referenced by Disable(), Enable(), IsEnabled(), and IsNoneEnabled().

◆ m_mask

int32_t ns3::LogComponent::m_mask
private

Blocked LogLevels.

Definition at line 420 of file log.h.

Referenced by SetMask().

◆ m_name

std::string ns3::LogComponent::m_name
private

LogComponent name.

Definition at line 421 of file log.h.

Referenced by EnvVarCheck(), and Name().


The documentation for this class was generated from the following files: