TrinityCore
Appender.h
Go to the documentation of this file.
1/*
2 * This file is part of the TrinityCore Project. See AUTHORS file for Copyright information
3 *
4 * This program is free software; you can redistribute it and/or modify it
5 * under the terms of the GNU General Public License as published by the
6 * Free Software Foundation; either version 2 of the License, or (at your
7 * option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
12 * more details.
13 *
14 * You should have received a copy of the GNU General Public License along
15 * with this program. If not, see <http://www.gnu.org/licenses/>.
16 */
17
18#ifndef APPENDER_H
19#define APPENDER_H
20
21#include "Define.h"
22#include "LogCommon.h"
23#include <stdexcept>
24#include <string>
25
26struct LogMessage;
27
29{
30 public:
32 Appender(Appender const&) = delete;
33 Appender(Appender&&) = delete;
34 Appender& operator=(Appender const&) = delete;
36 virtual ~Appender();
37
38 uint8 getId() const;
39 std::string const& getName() const;
40 virtual AppenderType getType() const = 0;
41 LogLevel getLogLevel() const;
42 AppenderFlags getFlags() const;
43
44 void setLogLevel(LogLevel);
45 void write(LogMessage* message);
46 static char const* getLogLevelString(LogLevel level);
47 virtual void setRealmId(uint32 /*realmId*/) { }
48
49 private:
50 virtual void _write(LogMessage const* /*message*/) = 0;
51
53 std::string name;
56};
57
58class TC_COMMON_API InvalidAppenderArgsException : public std::length_error
59{
60public:
61 explicit InvalidAppenderArgsException(std::string const& message) : std::length_error(message) { }
62};
63
64#endif
uint8_t uint8
Definition: Define.h:144
#define TC_COMMON_API
Definition: Define.h:99
uint32_t uint32
Definition: Define.h:142
uint16 flags
Definition: DisableMgr.cpp:49
AppenderFlags
Definition: LogCommon.h:50
@ APPENDER_FLAGS_NONE
Definition: LogCommon.h:51
AppenderType
Definition: LogCommon.h:40
LogLevel
Definition: LogCommon.h:25
@ LOG_LEVEL_DISABLED
Definition: LogCommon.h:26
virtual void _write(LogMessage const *)=0
std::string name
Definition: Appender.h:53
virtual AppenderType getType() const =0
uint8 id
Definition: Appender.h:52
LogLevel level
Definition: Appender.h:54
Appender & operator=(Appender const &)=delete
Appender(Appender &&)=delete
virtual ~Appender()
AppenderFlags flags
Definition: Appender.h:55
Appender & operator=(Appender &&)=delete
virtual void setRealmId(uint32)
Definition: Appender.h:47
Appender(Appender const &)=delete
InvalidAppenderArgsException(std::string const &message)
Definition: Appender.h:61
STL namespace.