Luanti 5.16.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
static LogTimestamp timestamp_mode = LOG_TIMESTAMP_WALL

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 ()

Static Private Member Functions

static std::string getLogTimestamp ()

Private Attributes

std::mutex m_mutex
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

Member Function Documentation

◆ addOutput() [1/2]

void Logger::addOutput ( ILogOutput * out)

References addOutputMaxLevel(), and LL_MAX.

Here is the call 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().

Here is the caller graph for this function:

◆ deregisterThread()

void Logger::deregisterThread ( )

References m_mutex, and m_thread_names.

◆ getLevelLabel()

const char * Logger::getLevelLabel ( LogLevel lev)
static

References ARRLEN, and LL_MAX.

Referenced by log().

Here is the caller graph for this function:

◆ getLogTimestamp()

std::string Logger::getLogTimestamp ( )
inlinestaticprivate

References porting::getTimeMs(), getTimestamp(), LOG_TIMESTAMP_NONE, LOG_TIMESTAMP_WALL, and timestamp_mode.

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 ( )
inlineprivate

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.

◆ 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(), getLogTimestamp(), getThreadName(), isLevelSilenced(), and logToOutputs().

Referenced by logToOutputs().

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 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.

◆ removeOutput()

LogLevelMask Logger::removeOutput ( ILogOutput * out)

◆ setLevelSilenced()

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

References m_silenced_levels.

◆ 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

◆ timestamp_mode

LogTimestamp Logger::timestamp_mode = LOG_TIMESTAMP_WALL
static

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