TrinityCore
Loading...
Searching...
No Matches
Log Class Reference

#include <Log.h>

Public Member Functions

 Log (Log const &)=delete
 
 Log (Log &&)=delete
 
Logoperator= (Log const &)=delete
 
Logoperator= (Log &&)=delete
 
void Initialize (Trinity::Asio::IoContext *ioContext)
 
void SetAsynchronous (Trinity::Asio::IoContext *ioContext)
 
void SetSynchronous ()
 
void LoadFromConfig ()
 
void Close ()
 
bool ShouldLog (std::string_view type, LogLevel level) const noexcept
 
Logger const * GetEnabledLogger (std::string_view type, LogLevel level) const noexcept
 
bool SetLogLevel (std::string const &name, int32 level, bool isLogger=true)
 
template<typename... Args>
void OutMessage (std::string_view filter, LogLevel level, Trinity::FormatString< Args... > fmt, Args &&... args) noexcept
 
template<typename... Args>
void OutMessageTo (Logger const *logger, std::string_view filter, LogLevel level, Trinity::FormatString< Args... > fmt, Args &&... args) noexcept
 
template<typename... Args>
void OutCommand (uint32 account, Trinity::FormatString< Args... > fmt, Args &&... args) noexcept
 
void OutCharDump (std::string const &str, uint32 account_id, uint64 guid, std::string const &name) const noexcept
 
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 () noexcept
 
template<typename StringOrStringView >
static constexpr std::string_view make_string_view (StringOrStringView const &stringOrStringView)
 
template<size_t CharArraySize>
static consteval std::string_view make_string_view (char const(&chars)[CharArraySize])
 
template<size_t CharArraySize>
static consteval Trinity::FormatStringView make_format_string_view (char const(&chars)[CharArraySize])
 

Private Member Functions

 Log ()
 
 ~Log ()
 
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 (Logger const *logger, std::string_view filter, LogLevel level, Trinity::FormatStringView messageFormat, Trinity::FormatArgs messageFormatArgs) const noexcept
 
void OutCommandImpl (uint32 account, Trinity::FormatStringView messageFormat, Trinity::FormatArgs messageFormatArgs) const noexcept
 

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 30 of file Log.cpp.

◆ ~Log()

Log::~Log ( )
private

Definition at line 36 of file Log.cpp.

+ Here is the call graph for this function:

◆ Log() [2/3]

Log::Log ( Log const &  )
delete

◆ Log() [3/3]

Log::Log ( Log &&  )
delete

Member Function Documentation

◆ Close()

void Log::Close ( )

Definition at line 324 of file Log.cpp.

+ Here is the caller graph for this function:

◆ CreateAppenderFromConfig()

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

Definition at line 115 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 56 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 175 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 120 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 47 of file Log.cpp.

+ Here is the caller graph for this function:

◆ GetEnabledLogger()

Logger const * Log::GetEnabledLogger ( std::string_view  type,
LogLevel  level 
) const
noexcept

Definition at line 348 of file Log.cpp.

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

◆ GetLoggerByType()

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

Definition at line 244 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 105 of file Log.h.

◆ GetLogsTimestamp()

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

Definition at line 106 of file Log.h.

◆ GetTimestampStr()

std::string Log::GetTimestampStr ( )
staticprivate

Definition at line 261 of file Log.cpp.

+ Here is the call graph for this function:

◆ Initialize()

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

Definition at line 368 of file Log.cpp.

+ Here is the call graph for this function:

◆ instance()

Log * Log::instance ( )
staticnoexcept

Definition at line 362 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 390 of file Log.cpp.

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

◆ make_format_string_view()

template<size_t CharArraySize>
static consteval Trinity::FormatStringView Log::make_format_string_view ( char const(&)  chars[CharArraySize])
inlinestatic

Definition at line 124 of file Log.h.

◆ make_string_view() [1/2]

template<size_t CharArraySize>
static consteval std::string_view Log::make_string_view ( char const(&)  chars[CharArraySize])
inlinestatic

Definition at line 118 of file Log.h.

◆ make_string_view() [2/2]

template<typename StringOrStringView >
static constexpr std::string_view Log::make_string_view ( StringOrStringView const &  stringOrStringView)
inlinestaticconstexpr

Definition at line 112 of file Log.h.

◆ NextAppenderId()

uint8 Log::NextAppenderId ( )
private

Definition at line 42 of file Log.cpp.

+ Here is the caller graph for this function:

◆ operator=() [1/2]

Log & Log::operator= ( Log &&  )
delete

◆ operator=() [2/2]

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

◆ OutCharDump()

void Log::OutCharDump ( std::string const &  str,
uint32  account_id,
uint64  guid,
std::string const &  name 
) const
noexcept

Definition at line 299 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 
)
inlinenoexcept

Definition at line 87 of file Log.h.

+ Here is the call graph for this function:

◆ OutCommandImpl()

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

Definition at line 231 of file Log.cpp.

+ Here is the call graph for this function:

◆ OutMessage()

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

Definition at line 75 of file Log.h.

+ Here is the call graph for this function:

◆ OutMessageImpl()

void Log::OutMessageImpl ( Logger const *  logger,
std::string_view  filter,
LogLevel  level,
Trinity::FormatStringView  messageFormat,
Trinity::FormatArgs  messageFormatArgs 
) const
privatenoexcept

Definition at line 220 of file Log.cpp.

+ Here is the call graph for this function:

◆ OutMessageTo()

template<typename... Args>
void Log::OutMessageTo ( Logger const *  logger,
std::string_view  filter,
LogLevel  level,
Trinity::FormatString< Args... >  fmt,
Args &&...  args 
)
inlinenoexcept

Definition at line 81 of file Log.h.

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

◆ ReadAppendersFromConfig()

void Log::ReadAppendersFromConfig ( )
private

Definition at line 180 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 187 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 100 of file Log.h.

◆ RegisterAppender() [2/2]

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

Definition at line 214 of file Log.cpp.

◆ SetAsynchronous()

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

Definition at line 374 of file Log.cpp.

+ Here is the caller graph for this function:

◆ SetLogLevel()

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

Definition at line 266 of file Log.cpp.

+ Here is the call graph for this function:

◆ SetRealmId()

void Log::SetRealmId ( uint32  id)

Definition at line 318 of file Log.cpp.

◆ SetSynchronous()

void Log::SetSynchronous ( )

Definition at line 383 of file Log.cpp.

◆ ShouldLog()

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

Definition at line 330 of file Log.cpp.

+ Here is the call graph for this function:

Member Data Documentation

◆ _ioContext

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

Definition at line 152 of file Log.h.

◆ _strand

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

Definition at line 153 of file Log.h.

◆ appenderFactory

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

Definition at line 143 of file Log.h.

◆ AppenderId

uint8 Log::AppenderId
private

Definition at line 146 of file Log.h.

◆ appenders

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

Definition at line 144 of file Log.h.

◆ loggers

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

Definition at line 145 of file Log.h.

◆ lowestLogLevel

LogLevel Log::lowestLogLevel
private

Definition at line 147 of file Log.h.

◆ m_logsDir

std::string Log::m_logsDir
private

Definition at line 149 of file Log.h.

◆ m_logsTimestamp

std::string Log::m_logsTimestamp
private

Definition at line 150 of file Log.h.


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