Minetest  5.4.0
Logger Class Reference

#include <log.h>

+ Collaboration diagram for Logger:

Public Member Functions

void addOutput (ILogOutput *out)
 
void addOutput (ILogOutput *out, LogLevel lev)
 
void addOutputMasked (ILogOutput *out, LogLevelMask mask)
 
void addOutputMaxLevel (ILogOutput *out, LogLevel lev)
 
LogLevelMask removeOutput (ILogOutput *out)
 
void setLevelSilenced (LogLevel lev, bool silenced)
 
void registerThread (const std::string &name)
 
void deregisterThread ()
 
void log (LogLevel lev, const std::string &text)
 
void logRaw (LogLevel lev, const std::string &text)
 
void setTraceEnabled (bool enable)
 
bool getTraceEnabled ()
 

Static Public Member Functions

static LogLevel stringToLevel (const std::string &name)
 
static const std::string getLevelLabel (LogLevel lev)
 

Static Public Attributes

static LogColor color_mode = LOG_COLOR_AUTO
 

Private Member Functions

void logToOutputsRaw (LogLevel, const std::string &line)
 
void logToOutputs (LogLevel, const std::string &combined, const std::string &time, const std::string &thread_name, const std::string &payload_text)
 
const std::string getThreadName ()
 

Private Attributes

std::vector< ILogOutput * > m_outputs [LL_MAX]
 
volatile bool m_silenced_levels [LL_MAX]
 
std::map< std::thread::id, std::string > m_thread_names
 
std::mutex m_mutex
 
bool m_trace_enabled
 

Member Function Documentation

◆ addOutput() [1/2]

void Logger::addOutput ( ILogOutput out)

References addOutputMaxLevel(), and LL_MAX.

Referenced by setup_log_params().

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

◆ addOutput() [2/2]

void Logger::addOutput ( ILogOutput out,
LogLevel  lev 
)

References m_outputs.

◆ addOutputMasked()

void Logger::addOutputMasked ( ILogOutput out,
LogLevelMask  mask 
)

◆ addOutputMaxLevel()

void Logger::addOutputMaxLevel ( ILogOutput out,
LogLevel  lev 
)

References LL_MAX, and m_outputs.

Referenced by addOutput(), init_log_streams(), main(), setup_log_params(), and LogOutputBuffer::updateLogLevel().

+ Here is the caller graph for this function:

◆ deregisterThread()

void Logger::deregisterThread ( )

References m_mutex, and m_thread_names.

Referenced by Thread::threadProc().

+ Here is the caller graph for this function:

◆ getLevelLabel()

const std::string Logger::getLevelLabel ( LogLevel  lev)
static

References ARRLEN, LL_MAX, and STATIC_ASSERT().

Referenced by log().

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

◆ getThreadName()

const std::string Logger::getThreadName ( )
private

References m_thread_names.

Referenced by log().

+ Here is the caller graph for this function:

◆ getTraceEnabled()

bool Logger::getTraceEnabled ( )
inline

References m_trace_enabled.

◆ log()

void Logger::log ( LogLevel  lev,
const std::string &  text 
)

References getLevelLabel(), getThreadName(), getTimestamp(), logToOutputs(), and m_silenced_levels.

Referenced by LogBuffer::flush(), ModApiUtil::l_log(), logToOutputs(), and MyEventReceiver::OnEvent().

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

◆ logRaw()

void Logger::logRaw ( LogLevel  lev,
const std::string &  text 
)

References logToOutputsRaw(), and m_silenced_levels.

Referenced by RawLogBuffer::flush(), and logToOutputsRaw().

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

◆ logToOutputs()

void Logger::logToOutputs ( LogLevel  lev,
const std::string &  combined,
const std::string &  time,
const std::string &  thread_name,
const std::string &  payload_text 
)
private

References log(), m_mutex, and m_outputs.

Referenced by log().

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

◆ logToOutputsRaw()

void Logger::logToOutputsRaw ( LogLevel  lev,
const std::string &  line 
)
private

References logRaw(), m_mutex, and m_outputs.

Referenced by logRaw().

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

◆ registerThread()

void Logger::registerThread ( const std::string &  name)

References m_mutex, and m_thread_names.

Referenced by main(), and Thread::threadProc().

+ Here is the caller graph for this function:

◆ removeOutput()

LogLevelMask Logger::removeOutput ( ILogOutput out)

References LL_MAX, LOGLEVEL_TO_MASKLEVEL, and m_outputs.

Referenced by LogOutputBuffer::~LogOutputBuffer(), init_log_streams(), setup_log_params(), and LogOutputBuffer::updateLogLevel().

+ Here is the caller graph for this function:

◆ setLevelSilenced()

void Logger::setLevelSilenced ( LogLevel  lev,
bool  silenced 
)

References m_silenced_levels.

Referenced by run_tests().

+ Here is the caller graph for this function:

◆ setTraceEnabled()

void Logger::setTraceEnabled ( bool  enable)
inline

References m_trace_enabled.

Referenced by setup_log_params().

+ Here is the caller graph for this function:

◆ stringToLevel()

LogLevel Logger::stringToLevel ( const std::string &  name)
static

References LL_ACTION, LL_ERROR, LL_INFO, LL_MAX, LL_NONE, LL_VERBOSE, and LL_WARNING.

Referenced by init_log_streams(), ModApiUtil::l_log(), and LogOutputBuffer::updateLogLevel().

+ Here is the caller graph for this function:

Member Data Documentation

◆ color_mode

LogColor Logger::color_mode = LOG_COLOR_AUTO
static

◆ m_mutex

std::mutex Logger::m_mutex
mutableprivate

◆ m_outputs

std::vector<ILogOutput *> Logger::m_outputs[LL_MAX]
private

◆ m_silenced_levels

volatile bool Logger::m_silenced_levels[LL_MAX]
private

Referenced by log(), logRaw(), and setLevelSilenced().

◆ m_thread_names

std::map<std::thread::id, std::string> Logger::m_thread_names
private

◆ m_trace_enabled

bool Logger::m_trace_enabled
private

Referenced by getTraceEnabled(), and setTraceEnabled().


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