LogBackend.hpp
Go to the documentation of this file.
1/*
2 Copyright 2015, 2016 Statoil ASA.
3 Copyright 2016 SINTEF ICT, Applied Mathematics.
4
5 This file is part of the Open Porous Media project (OPM).
6
7 OPM is free software: you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation, either version 3 of the License, or
10 (at your option) any later version.
11
12 OPM is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
16
17 You should have received a copy of the GNU General Public License
18 along with OPM. If not, see <http://www.gnu.org/licenses/>.
19 */
20
21
22#ifndef OPM_LOGBACKEND_HPP
23#define OPM_LOGBACKEND_HPP
24
27#include <cstdint>
28#include <string>
29#include <memory>
30
31namespace Opm
32{
33
36 {
37 public:
39 explicit LogBackend(int64_t mask);
40
42 virtual ~LogBackend();
43
45 void setMessageFormatter(std::shared_ptr<MessageFormatterInterface> formatter);
46
48 void setMessageLimiter(std::shared_ptr<MessageLimiter> limiter);
49
51 void addMessage(int64_t messageFlag, const std::string& message);
52
54 void addTaggedMessage(int64_t messageFlag,
55 const std::string& messageTag,
56 const std::string& message);
57
60 int64_t getMask() const;
61
62 protected:
67 virtual void addMessageUnconditionally(int64_t messageFlag,
68 const std::string& message) = 0;
69
71 std::string formatMessage(int64_t messageFlag, const std::string& message);
72
73 private:
76 bool includeMessage(int64_t messageFlag, const std::string& messageTag);
77
78 int64_t m_mask;
79 std::shared_ptr<MessageFormatterInterface> m_formatter;
80 std::shared_ptr<MessageLimiter> m_limiter;
81 };
82
83} // namespace LogBackend
84
85
86#endif
const char *const string
Definition: cJSON.h:170
Abstract interface class for log backends.
Definition: LogBackend.hpp:36
LogBackend(int64_t mask)
Construct with given message mask.
std::string formatMessage(int64_t messageFlag, const std::string &message)
Return decorated version of message depending on configureDecoration() arguments.
int64_t getMask() const
void setMessageFormatter(std::shared_ptr< MessageFormatterInterface > formatter)
Configure how formatMessage() will modify message strings.
void setMessageLimiter(std::shared_ptr< MessageLimiter > limiter)
Configure how message tags will be used to limit messages.
virtual ~LogBackend()
Virtual destructor to enable inheritance.
void addMessage(int64_t messageFlag, const std::string &message)
Add a message to the backend if accepted by the message limiter.
virtual void addMessageUnconditionally(int64_t messageFlag, const std::string &message)=0
void addTaggedMessage(int64_t messageFlag, const std::string &messageTag, const std::string &message)
Add a tagged message to the backend if accepted by the message limiter.
Definition: A.hpp:4