AzerothCore 3.3.5a
OpenSource WoW Emulator
Loading...
Searching...
No Matches
AppenderDB Class Reference

#include "AppenderDB.h"

Inheritance diagram for AppenderDB:
Appender

Public Member Functions

 AppenderDB (uint8 id, std::string const &name, LogLevel level, AppenderFlags flags, std::vector< std::string_view > const &args)
 
 ~AppenderDB ()
 
void setRealmId (uint32 realmId) override
 
AppenderType getType () const override
 
- Public Member Functions inherited from Appender
 Appender (uint8 _id, std::string const &name, LogLevel level=LOG_LEVEL_DISABLED, AppenderFlags flags=APPENDER_FLAGS_NONE)
 
virtual ~Appender ()
 
uint8 getId () const
 
std::string const & getName () const
 
virtual AppenderType getType () const =0
 
LogLevel getLogLevel () const
 
AppenderFlags getFlags () const
 
void setLogLevel (LogLevel)
 
void write (LogMessage *message)
 
virtual void setRealmId (uint32)
 

Static Public Attributes

static constexpr AppenderType type = APPENDER_DB
 

Private Member Functions

void _write (LogMessage const *message) override
 

Private Attributes

uint32 realmId
 
bool enabled
 

Additional Inherited Members

- Static Public Member Functions inherited from Appender
static char const * getLogLevelString (LogLevel level)
 

Detailed Description

Constructor & Destructor Documentation

◆ AppenderDB()

AppenderDB::AppenderDB ( uint8  id,
std::string const &  name,
LogLevel  level,
AppenderFlags  flags,
std::vector< std::string_view > const &  args 
)
25 : Appender(id, name, level), realmId(0), enabled(false) { }
Definition: Appender.h:29
std::string name
Definition: Appender.h:49
LogLevel level
Definition: Appender.h:50
bool enabled
Definition: AppenderDB.h:37
uint32 realmId
Definition: AppenderDB.h:36

◆ ~AppenderDB()

AppenderDB::~AppenderDB ( )
27{ }

Member Function Documentation

◆ _write()

void AppenderDB::_write ( LogMessage const *  message)
overrideprivatevirtual

Implements Appender.

30{
31 // Avoid infinite loop, Execute triggers Logging with "sql.sql" type
32 if (!enabled || (message->type.find("sql") != std::string::npos))
33 return;
34
36 stmt->SetData(0, message->mtime.count());
37 stmt->SetData(1, realmId);
38 stmt->SetData(2, message->type);
39 stmt->SetData(3, uint8(message->level));
40 stmt->SetData(4, message->text);
41 LoginDatabase.Execute(stmt);
42}
std::uint8_t uint8
Definition: Define.h:109
@ LOGIN_INS_LOG
Definition: LoginDatabase.h:113
DatabaseWorkerPool< LoginDatabaseConnection > LoginDatabase
Accessor to the realm/login database.
Definition: DatabaseEnv.cpp:22
Definition: PreparedStatement.h:158
Acore::Types::is_default< T > SetData(const uint8 index, T value)
Definition: PreparedStatement.h:78

References enabled, LogMessage::level, LOGIN_INS_LOG, LoginDatabase, LogMessage::mtime, realmId, PreparedStatementBase::SetData(), LogMessage::text, and LogMessage::type.

◆ getType()

AppenderType AppenderDB::getType ( ) const
inlineoverridevirtual

Implements Appender.

33{ return type; }
static constexpr AppenderType type
Definition: AppenderDB.h:27

References type.

◆ setRealmId()

void AppenderDB::setRealmId ( uint32  realmId)
overridevirtual

Reimplemented from Appender.

45{
46 enabled = true;
47 realmId = _realmId;
48}

References enabled, and realmId.

Member Data Documentation

◆ enabled

bool AppenderDB::enabled
private

Referenced by _write(), and setRealmId().

◆ realmId

uint32 AppenderDB::realmId
private

Referenced by _write(), and setRealmId().

◆ type

constexpr AppenderType AppenderDB::type = APPENDER_DB
staticconstexpr

Referenced by getType().