TrinityCore
Log Class Reference

#include <Log.h>

Public Member Functions

void Initialize (Trinity::Asio::IoContext *ioContext)
 
void SetSynchronous ()
 
void LoadFromConfig ()
 
void Close ()
 
bool ShouldLog (std::string_view type, LogLevel level) const
 
bool SetLogLevel (std::string const &name, int32 level, bool isLogger=true)
 
template<typename... Args>
void OutMessage (std::string_view filter, LogLevel const level, Trinity::FormatString< Args... > fmt, Args &&... args)
 
template<typename... Args>
void OutCommand (uint32 account, Trinity::FormatString< Args... > fmt, Args &&... args)
 
void OutCharDump (char const *str, uint32 account_id, uint64 guid, char const *name)
 
void SetRealmId (uint32 id)
 
template<class AppenderImpl >
void RegisterAppender ()
 
std::string const & GetLogsDir () const
 
std::string const & GetLogsTimestamp () const
 
void CreateAppenderFromConfigLine (std::string const &name, std::string const &options)
 
void CreateLoggerFromConfigLine (std::string const &name, std::string const &options)
 

Static Public Member Functions

static Loginstance ()
 

Private Member Functions

 Log ()
 
 ~Log ()
 
 Log (Log const &)=delete
 
 Log (Log &&)=delete
 
Logoperator= (Log const &)=delete
 
Logoperator= (Log &&)=delete
 
void write (std::unique_ptr< LogMessage > msg) const
 
Logger const * GetLoggerByType (std::string_view type) const
 
AppenderGetAppenderByName (std::string_view name)
 
uint8 NextAppenderId ()
 
void CreateAppenderFromConfig (std::string const &name)
 
void CreateLoggerFromConfig (std::string const &name)
 
void ReadAppendersFromConfig ()
 
void ReadLoggersFromConfig ()
 
void RegisterAppender (uint8 index, AppenderCreatorFn appenderCreateFn)
 
void OutMessageImpl (std::string_view filter, LogLevel level, Trinity::FormatStringView messageFormat, Trinity::FormatArgs messageFormatArgs)
 
void OutCommandImpl (uint32 account, Trinity::FormatStringView messageFormat, Trinity::FormatArgs messageFormatArgs)
 

Static Private Member Functions

static std::string GetTimestampStr ()
 

Private Attributes

std::unordered_map< uint8, AppenderCreatorFnappenderFactory
 
std::unordered_map< uint8, std::unique_ptr< Appender > > appenders
 
std::unordered_map< std::string_view, std::unique_ptr< Logger > > loggers
 
uint8 AppenderId
 
LogLevel lowestLogLevel
 
std::string m_logsDir
 
std::string m_logsTimestamp
 
Trinity::Asio::IoContext_ioContext
 
Trinity::Asio::Strand_strand
 

Detailed Description

Definition at line 51 of file Log.h.

Constructor & Destructor Documentation

◆ Log() [1/3]

Log::Log ( )
private

Definition at line 32 of file Log.cpp.

+ Here is the call graph for this function:

◆ ~Log()

Log::~Log ( )
private

Definition at line 39 of file Log.cpp.

+ Here is the call graph for this function:

◆ Log() [2/3]

Log::Log ( Log const &  )
privatedelete

◆ Log() [3/3]

Log::Log ( Log &&  )
privatedelete

Member Function Documentation

◆ Close()

void Log::Close ( )

Definition at line 347 of file Log.cpp.

+ Here is the caller graph for this function:

◆ CreateAppenderFromConfig()

void Log::CreateAppenderFromConfig ( std::string const &  name)
private

Definition at line 118 of file Log.cpp.

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

◆ CreateAppenderFromConfigLine()

void Log::CreateAppenderFromConfigLine ( std::string const &  name,
std::string const &  options 
)

Definition at line 59 of file Log.cpp.

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

◆ CreateLoggerFromConfig()

void Log::CreateLoggerFromConfig ( std::string const &  name)
private

Definition at line 178 of file Log.cpp.

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

◆ CreateLoggerFromConfigLine()

void Log::CreateLoggerFromConfigLine ( std::string const &  name,
std::string const &  options 
)

Definition at line 123 of file Log.cpp.

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

◆ GetAppenderByName()

Appender * Log::GetAppenderByName ( std::string_view  name)
private

Definition at line 50 of file Log.cpp.

+ Here is the caller graph for this function:

◆ GetLoggerByType()

Logger const * Log::GetLoggerByType ( std::string_view  type) const
private

Definition at line 247 of file Log.cpp.

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

◆ GetLogsDir()

std::string const & Log::GetLogsDir ( ) const
inline

Definition at line 96 of file Log.h.

◆ GetLogsTimestamp()

std::string const & Log::GetLogsTimestamp ( ) const
inline

Definition at line 97 of file Log.h.

◆ GetTimestampStr()

std::string Log::GetTimestampStr ( )
staticprivate

Definition at line 264 of file Log.cpp.

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

◆ Initialize()

void Log::Initialize ( Trinity::Asio::IoContext ioContext)

Definition at line 377 of file Log.cpp.

+ Here is the call graph for this function:

◆ instance()

Log * Log::instance ( )
static

Definition at line 371 of file Log.cpp.

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

◆ LoadFromConfig()

void Log::LoadFromConfig ( )

Definition at line 395 of file Log.cpp.

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

◆ NextAppenderId()

uint8 Log::NextAppenderId ( )
private

Definition at line 45 of file Log.cpp.

+ Here is the caller graph for this function:

◆ operator=() [1/2]

Log & Log::operator= ( Log &&  )
privatedelete

◆ operator=() [2/2]

Log & Log::operator= ( Log const &  )
privatedelete

◆ OutCharDump()

void Log::OutCharDump ( char const *  str,
uint32  account_id,
uint64  guid,
char const *  name 
)

Definition at line 323 of file Log.cpp.

+ Here is the call graph for this function:

◆ OutCommand()

template<typename... Args>
void Log::OutCommand ( uint32  account,
Trinity::FormatString< Args... >  fmt,
Args &&...  args 
)
inline

Definition at line 78 of file Log.h.

+ Here is the call graph for this function:

◆ OutCommandImpl()

void Log::OutCommandImpl ( uint32  account,
Trinity::FormatStringView  messageFormat,
Trinity::FormatArgs  messageFormatArgs 
)
private

Definition at line 229 of file Log.cpp.

+ Here is the call graph for this function:

◆ OutMessage()

template<typename... Args>
void Log::OutMessage ( std::string_view  filter,
LogLevel const  level,
Trinity::FormatString< Args... >  fmt,
Args &&...  args 
)
inline

Definition at line 72 of file Log.h.

+ Here is the call graph for this function:

◆ OutMessageImpl()

void Log::OutMessageImpl ( std::string_view  filter,
LogLevel  level,
Trinity::FormatStringView  messageFormat,
Trinity::FormatArgs  messageFormatArgs 
)
private

Definition at line 224 of file Log.cpp.

+ Here is the call graph for this function:

◆ ReadAppendersFromConfig()

void Log::ReadAppendersFromConfig ( )
private

Definition at line 183 of file Log.cpp.

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

◆ ReadLoggersFromConfig()

void Log::ReadLoggersFromConfig ( )
private

Definition at line 190 of file Log.cpp.

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

◆ RegisterAppender() [1/2]

template<class AppenderImpl >
void Log::RegisterAppender ( )
inline

Definition at line 91 of file Log.h.

◆ RegisterAppender() [2/2]

void Log::RegisterAppender ( uint8  index,
AppenderCreatorFn  appenderCreateFn 
)
private

Definition at line 217 of file Log.cpp.

◆ SetLogLevel()

bool Log::SetLogLevel ( std::string const &  name,
int32  level,
bool  isLogger = true 
)

Definition at line 290 of file Log.cpp.

+ Here is the call graph for this function:

◆ SetRealmId()

void Log::SetRealmId ( uint32  id)

Definition at line 341 of file Log.cpp.

◆ SetSynchronous()

void Log::SetSynchronous ( )

Definition at line 388 of file Log.cpp.

◆ ShouldLog()

bool Log::ShouldLog ( std::string_view  type,
LogLevel  level 
) const

Definition at line 353 of file Log.cpp.

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

◆ write()

void Log::write ( std::unique_ptr< LogMessage msg) const
private

Definition at line 234 of file Log.cpp.

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

Member Data Documentation

◆ _ioContext

Trinity::Asio::IoContext* Log::_ioContext
private

Definition at line 126 of file Log.h.

◆ _strand

Trinity::Asio::Strand* Log::_strand
private

Definition at line 127 of file Log.h.

◆ appenderFactory

std::unordered_map<uint8, AppenderCreatorFn> Log::appenderFactory
private

Definition at line 117 of file Log.h.

◆ AppenderId

uint8 Log::AppenderId
private

Definition at line 120 of file Log.h.

◆ appenders

std::unordered_map<uint8, std::unique_ptr<Appender> > Log::appenders
private

Definition at line 118 of file Log.h.

◆ loggers

std::unordered_map<std::string_view, std::unique_ptr<Logger> > Log::loggers
private

Definition at line 119 of file Log.h.

◆ lowestLogLevel

LogLevel Log::lowestLogLevel
private

Definition at line 121 of file Log.h.

◆ m_logsDir

std::string Log::m_logsDir
private

Definition at line 123 of file Log.h.

◆ m_logsTimestamp

std::string Log::m_logsTimestamp
private

Definition at line 124 of file Log.h.


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