TrinityCore
Loading...
Searching...
No Matches
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 <string_view>
26
27struct LogMessage;
28
30{
31 public:
33 Appender(Appender const&) = delete;
34 Appender(Appender&&) = delete;
35 Appender& operator=(Appender const&) = delete;
37 virtual ~Appender();
38
39 uint8 getId() const;
40 std::string const& getName() const;
41 virtual AppenderType getType() const = 0;
42 LogLevel getLogLevel() const;
43 AppenderFlags getFlags() const;
44
45 void setLogLevel(LogLevel);
46 void write(LogMessage* message);
47 static std::string_view getLogLevelString(LogLevel level);
48 virtual void setRealmId(uint32 /*realmId*/) { }
49
50 private:
51 virtual void _write(LogMessage const* /*message*/) = 0;
52
54 std::string name;
57};
58
59class TC_COMMON_API InvalidAppenderArgsException : public std::length_error
60{
61public:
62 explicit InvalidAppenderArgsException(std::string const& message) : std::length_error(message) { }
63};
64
65#endif
uint8_t uint8
Definition Define.h:156
#define TC_COMMON_API
Definition Define.h:99
uint32_t uint32
Definition Define.h:154
uint16 flags
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:54
virtual AppenderType getType() const =0
uint8 id
Definition Appender.h:53
LogLevel level
Definition Appender.h:55
Appender & operator=(Appender const &)=delete
Appender(Appender &&)=delete
virtual ~Appender()
AppenderFlags flags
Definition Appender.h:56
Appender & operator=(Appender &&)=delete
virtual void setRealmId(uint32)
Definition Appender.h:48
Appender(Appender const &)=delete
InvalidAppenderArgsException(std::string const &message)
Definition Appender.h:62
STL namespace.