31 #include <type_traits>
32 #include <unordered_map>
202 #define NS_LOG_COMPONENT_DEFINE(name) \
203 static ns3::LogComponent g_log = ns3::LogComponent(name, __FILE__)
213 #define NS_LOG_COMPONENT_DEFINE_MASK(name, mask) \
214 static ns3::LogComponent g_log = ns3::LogComponent(name, __FILE__, mask)
225 #define NS_LOG_TEMPLATE_DECLARE LogComponent& g_log
236 #define NS_LOG_TEMPLATE_DEFINE(name) g_log(GetLogComponent(name))
246 #define NS_LOG_STATIC_TEMPLATE_DEFINE(name) \
247 static LogComponent& g_log [[maybe_unused]] = GetLogComponent(name)
254 #define NS_LOG_ERROR(msg) NS_LOG(ns3::LOG_ERROR, msg)
261 #define NS_LOG_WARN(msg) NS_LOG(ns3::LOG_WARN, msg)
268 #define NS_LOG_DEBUG(msg) NS_LOG(ns3::LOG_DEBUG, msg)
275 #define NS_LOG_INFO(msg) NS_LOG(ns3::LOG_INFO, msg)
282 #define NS_LOG_LOGIC(msg) NS_LOG(ns3::LOG_LOGIC, msg)
370 std::string
Name()
const;
375 std::string
File()
const;
454 template <
typename T>
463 template <
typename T>
474 template <
typename T>
480 if constexpr (std::is_convertible_v<T, std::string>)
482 m_os <<
"\"" << param <<
"\"";
484 else if constexpr (std::is_arithmetic_v<T>)
497 template <
typename T>
501 for (
const auto& i : vector)
A single log component configuration.
static ComponentList * GetComponentList()
Get the list of LogComponents.
void Enable(const LogLevel level)
Enable this LogComponent at level.
bool IsEnabled(const LogLevel level) const
Check if this LogComponent is enabled for level.
std::string File() const
Get the compilation unit defining this LogComponent.
int32_t m_levels
Enabled LogLevels.
void Disable(const LogLevel level)
Disable logging at level for this LogComponent.
static std::string GetLevelLabel(const LogLevel level)
Get the string label for the given LogLevel.
void EnvVarCheck()
Parse the NS_LOG environment variable for options relating to this LogComponent.
std::string m_file
File defining this LogComponent.
bool IsNoneEnabled() const
Check if all levels are disabled.
std::string Name() const
Get the name of this LogComponent.
std::unordered_map< std::string, LogComponent * > ComponentList
LogComponent name map.
int32_t m_mask
Blocked LogLevels.
LogComponent(const std::string &name, const std::string &file, const LogLevel mask=LOG_NONE)
Constructor.
void SetMask(const LogLevel level)
Prevent the enabling of a specific LogLevel.
std::string m_name
LogComponent name.
Insert , when streaming function arguments.
void CommaRest()
Add , before every parameter after the first.
bool m_first
First argument flag, doesn't get ,.
ParameterLogger & operator<<(const T ¶m)
Write a function parameter on the output stream, separating parameters after the first by ,...
ParameterLogger(std::ostream &os)
Constructor.
std::ostream & m_os
Underlying output stream.
Definition of empty logging macros and the NS_LOG_NOOP_INTERNAL macro.
NS_LOG and related logging macro definitions.
Every class exported by the ns3 library is enclosed in the ns3 namespace.
void LogComponentEnable(const std::string &name, LogLevel level)
Enable the logging output associated with that log component.
void LogSetTimePrinter(TimePrinter printer)
Set the TimePrinter function to be used to prepend log messages with the simulation time.
void(* TimePrinter)(std::ostream &os)
Function signature for features requiring a time formatter, such as logging or ShowProgress.
void(* NodePrinter)(std::ostream &os)
Function signature for prepending the node id to a log message.
NodePrinter LogGetNodePrinter()
Get the LogNodePrinter function currently in use.
void LogComponentDisable(const std::string &name, LogLevel level)
Disable the logging output associated with that log component.
LogLevel
Logging severity classes and levels.
@ LOG_LEVEL_ALL
Print everything.
@ LOG_PREFIX_FUNC
Prefix all trace prints with function.
@ LOG_LEVEL_LOGIC
LOG_LOGIC and above.
@ LOG_PREFIX_TIME
Prefix all trace prints with simulation time.
@ LOG_FUNCTION
Function tracing for non-trivial function calls.
@ LOG_ERROR
Serious error messages only.
@ LOG_WARN
Warning messages.
@ LOG_INFO
Something happened to change state.
@ LOG_PREFIX_ALL
All prefixes.
@ LOG_LEVEL_FUNCTION
LOG_FUNCTION and above.
@ LOG_LEVEL_ERROR
LOG_ERROR and above.
@ LOG_ALL
Print everything.
@ LOG_LEVEL_WARN
LOG_WARN and above.
@ LOG_LEVEL_DEBUG
LOG_DEBUG and above.
@ LOG_PREFIX_LEVEL
Prefix all trace prints with log level (severity).
@ LOG_LOGIC
Debugging logs for key branches and decisions in a function.
@ LOG_PREFIX_NODE
Prefix all trace prints with simulation node.
@ LOG_LEVEL_INFO
LOG_INFO and above.
@ LOG_DEBUG
Full voluminous logging to support debugging.
TimePrinter LogGetTimePrinter()
Get the LogTimePrinter function currently in use.
void LogComponentDisableAll(LogLevel level)
Disable all logging for all components.
LogComponent & GetLogComponent(const std::string name)
Get the LogComponent registered with the given name.
void LogComponentEnableAll(LogLevel level)
Enable the logging output for all registered log components.
void LogSetNodePrinter(NodePrinter printer)
Set the LogNodePrinter function to be used to prepend log messages with the node id.
void LogComponentPrintList()
Print the list of logging messages available.
Declaration of ns3::NodePrinter function pointer type and ns3::DefaultNodePrinter function.
Declaration of ns3::TimePrinter function pointer type and ns3::DefaultTimePrinter function.