A Discrete-Event Network Simulator
API
Loading...
Searching...
No Matches
ns3::anonymous_namespace{log.cc} Namespace Reference

Unnamed namespace for log line assembly buffers. More...

Classes

struct  LogLine
 A memory buffer and the ostream assembling a log line into it. More...
class  LogLineBuf
 A streambuf appending to a std::string whose capacity is reused between log lines, so steady-state logging does not allocate. More...

Functions

void EmitLine (std::string &line)
 Write an assembled log line to std::clog, terminated by a newline, and empty it.
LogLine & GetLogLine ()
void WriteStdErr (const char *s, std::size_t n)
 Write to the standard error file descriptor, bypassing std::clog.

Variables

LogLine * g_logLine = nullptr
 The thread's log line, once created.
bool g_logLineDestroyed = false
 Whether this thread's LogLine has been destroyed.

Detailed Description

Unnamed namespace for log line assembly buffers.

Function Documentation

◆ EmitLine()

void ns3::anonymous_namespace{log.cc}::EmitLine ( std::string & line)

Write an assembled log line to std::clog, terminated by a newline, and empty it.

Parameters
[in,out]lineThe line to emit.

Definition at line 251 of file log.cc.

References EmitLine().

Referenced by ns3::anonymous_namespace{log.cc}::LogLine::~LogLine(), and EmitLine().

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

◆ GetLogLine()

LogLine & ns3::anonymous_namespace{log.cc}::GetLogLine ( )
Returns
The thread-local log line buffer.

Definition at line 300 of file log.cc.

References g_logLine, and GetLogLine().

Referenced by GetLogLine().

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

◆ WriteStdErr()

void ns3::anonymous_namespace{log.cc}::WriteStdErr ( const char * s,
std::size_t n )

Write to the standard error file descriptor, bypassing std::clog.

Parameters
[in]sThe characters to write.
[in]nThe number of characters to write.

Definition at line 366 of file log.cc.

References WriteStdErr().

Referenced by WriteStdErr().

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

Variable Documentation

◆ g_logLine

LogLine* ns3::anonymous_namespace{log.cc}::g_logLine = nullptr
thread_local

The thread's log line, once created.

A plain pointer, so a signal handler can reach the line being assembled without running the thread_local initialization it may have interrupted.

Definition at line 296 of file log.cc.

Referenced by GetLogLine().

◆ g_logLineDestroyed

bool ns3::anonymous_namespace{log.cc}::g_logLineDestroyed = false
thread_local

Whether this thread's LogLine has been destroyed.

Trivially destructible, so it remains readable during program shutdown, after the buffer's own thread_local destructor has run. Core itself logs during static destruction (e.g. Time::Clear() from ~Time of static attribute defaults), so this must be handled.

Definition at line 267 of file log.cc.

Referenced by ns3::anonymous_namespace{log.cc}::LogLine::~LogLine().