Luanti 5.11.0-dev
 
Loading...
Searching...
No Matches
Logger Class Reference

#include <log_internal.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 (std::string_view name)
 
void deregisterThread ()
 
void log (LogLevel lev, std::string_view text)
 
void logRaw (LogLevel lev, std::string_view text)
 
bool hasOutput (LogLevel level)
 
bool isLevelSilenced (LogLevel level)
 

Static Public Member Functions

static LogLevel stringToLevel (std::string_view name)
 
static const char * getLevelLabel (LogLevel lev)
 

Static Public Attributes

static LogColor color_mode = LOG_COLOR_AUTO
 

Private Member Functions

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

Private Attributes

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

Member Function Documentation

◆ addOutput() [1/2]

void Logger::addOutput ( ILogOutput * out)

References addOutputMaxLevel(), and LL_MAX.

Referenced by CaptureLogOutput::CaptureLogOutput(), and 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 addOutputMasked(), and LOGLEVEL_TO_MASKLEVEL.

+ Here is the call graph for this function:

◆ addOutputMasked()

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

References LL_MAX, LOGLEVEL_TO_MASKLEVEL, m_has_outputs, m_mutex, and m_outputs.

Referenced by addOutput().

+ Here is the caller graph for this function:

◆ addOutputMaxLevel()

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

References LL_MAX, m_has_outputs, m_mutex, and m_outputs.

Referenced by addOutput(), init_log_streams(), main(), CaptureLogOutput::setLogLevel(), and setup_log_params().

+ 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 char * Logger::getLevelLabel ( LogLevel lev)
static

References ARRLEN, and LL_MAX.

Referenced by log().

+ 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:

◆ hasOutput()

bool Logger::hasOutput ( LogLevel level)
inline

References m_has_outputs.

Referenced by LevelTarget::hasOutput().

+ Here is the caller graph for this function:

◆ isLevelSilenced()

bool Logger::isLevelSilenced ( LogLevel level)
inline

References m_silenced_levels.

Referenced by log(), and logRaw().

+ Here is the caller graph for this function:

◆ log()

void Logger::log ( LogLevel lev,
std::string_view text )

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

Referenced by ModApiUtil::l_log(), LevelTarget::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,
std::string_view text )

References isLevelSilenced(), and logToOutputsRaw().

Referenced by LevelTarget::log(), 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,
std::string_view 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,
std::string_view 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 ( std::string_view 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, m_has_outputs, m_mutex, and m_outputs.

Referenced by CaptureLogOutput::~CaptureLogOutput(), init_log_streams(), CaptureLogOutput::setLogLevel(), and setup_log_params().

+ Here is the caller graph for this function:

◆ setLevelSilenced()

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

References m_silenced_levels.

Referenced by run_tests(), and run_tests().

+ Here is the caller graph for this function:

◆ stringToLevel()

LogLevel Logger::stringToLevel ( std::string_view name)
static

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

Referenced by init_log_streams(), ModApiUtil::l_log(), and Game::readSettings().

+ Here is the caller graph for this function:

Member Data Documentation

◆ color_mode

LogColor Logger::color_mode = LOG_COLOR_AUTO
static

◆ m_has_outputs

std::atomic<bool> Logger::m_has_outputs[LL_MAX]
private

◆ m_mutex

◆ m_outputs

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

◆ m_silenced_levels

std::atomic<bool> Logger::m_silenced_levels[LL_MAX]
private

◆ m_thread_names

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

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