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#include <vector>
26
27struct LogMessage;
28
30{
31 public:
32 Appender(uint8 _id, std::string const& name, LogLevel level = LOG_LEVEL_DISABLED, AppenderFlags flags = APPENDER_FLAGS_NONE);
33 virtual ~Appender();
34
35 uint8 getId() const;
36 std::string const& getName() const;
37 virtual AppenderType getType() const = 0;
38 LogLevel getLogLevel() const;
39 AppenderFlags getFlags() const;
40
41 void setLogLevel(LogLevel);
42 void write(LogMessage* message);
43 static char const* getLogLevelString(LogLevel level);
44 virtual void setRealmId(uint32 /*realmId*/) { }
45
46 private:
47 virtual void _write(LogMessage const* /*message*/) = 0;
48
50 std::string name;
53};
54
55class TC_COMMON_API InvalidAppenderArgsException : public std::length_error
56{
57public:
58 explicit InvalidAppenderArgsException(std::string const& message) : std::length_error(message) { }
59};
60
61#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:50
virtual AppenderType getType() const =0
uint8 id
Definition: Appender.h:49
LogLevel level
Definition: Appender.h:51
AppenderFlags flags
Definition: Appender.h:52
virtual void setRealmId(uint32)
Definition: Appender.h:44
InvalidAppenderArgsException(std::string const &message)
Definition: Appender.h:58
STL namespace.