OpmLog.hpp
Go to the documentation of this file.
1/*
2 Copyright 2014 Statoil ASA.
3
4 This file is part of the Open Porous Media project (OPM).
5
6 OPM is free software: you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation, either version 3 of the License, or
9 (at your option) any later version.
10
11 OPM is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
15
16 You should have received a copy of the GNU General Public License
17 along with OPM. If not, see <http://www.gnu.org/licenses/>.
18*/
19
20#ifndef OPMLOG_HPP
21#define OPMLOG_HPP
22
23#include <memory>
24#include <cstdint>
25
28
29namespace Opm {
30
31 class LogBackend;
32
33/*
34 The OpmLog class is a fully static class which manages a proper
35 Logger instance.
36*/
37
38
39class OpmLog {
40
41public:
42 static void addMessage(int64_t messageFlag , const std::string& message);
43 static void addTaggedMessage(int64_t messageFlag, const std::string& tag, const std::string& message);
44
45 static void info(const std::string& message);
46 static void warning(const std::string& message);
47 static void error(const std::string& message);
48 static void problem(const std::string& message);
49 static void bug(const std::string& message);
50 static void debug(const std::string& message);
51 static void note(const std::string& message);
52
53 static void info(const std::string& tag, const std::string& message);
54 static void warning(const std::string& tag, const std::string& message);
55 static void error(const std::string& tag, const std::string& message);
56 static void problem(const std::string& tag, const std::string& message);
57 static void bug(const std::string& tag, const std::string& message);
58 static void debug(const std::string& tag, const std::string& message);
59 static void note(const std::string& tag, const std::string& message);
60
61 static bool hasBackend( const std::string& backendName );
62 static void addBackend(const std::string& name , std::shared_ptr<LogBackend> backend);
63 static bool removeBackend(const std::string& name);
64 static void removeAllBackends();
65 static bool enabledMessageType( int64_t messageType );
66 static void addMessageType( int64_t messageType , const std::string& prefix);
67
74 static void setupSimpleDefaultLogging(const bool use_prefix = true,
75 const bool use_color_coding = true,
76 const int message_limit = 10);
77
78 template <class BackendType>
79 static std::shared_ptr<BackendType> getBackend(const std::string& name) {
80 auto logger = getLogger();
81 return logger->getBackend<BackendType>(name);
82 }
83
84 template <class BackendType>
85 static std::shared_ptr<BackendType> popBackend(const std::string& name) {
86 auto logger = getLogger();
87 return logger->popBackend<BackendType>(name);
88 }
89
90
91private:
92 static std::shared_ptr<Logger> getLogger();
93 static std::shared_ptr<Logger> m_logger;
94};
95
96
97}
98
99
100
101
102#endif
const char *const name
Definition: cJSON.h:258
const char *const string
Definition: cJSON.h:170
Definition: OpmLog.hpp:39
static void warning(const std::string &tag, const std::string &message)
static void info(const std::string &message)
static void removeAllBackends()
static void info(const std::string &tag, const std::string &message)
static void problem(const std::string &tag, const std::string &message)
static bool hasBackend(const std::string &backendName)
static void error(const std::string &message)
static void debug(const std::string &tag, const std::string &message)
static void addBackend(const std::string &name, std::shared_ptr< LogBackend > backend)
static void error(const std::string &tag, const std::string &message)
static void debug(const std::string &message)
static void note(const std::string &tag, const std::string &message)
static void bug(const std::string &tag, const std::string &message)
static void problem(const std::string &message)
static void note(const std::string &message)
static void addMessageType(int64_t messageType, const std::string &prefix)
static bool removeBackend(const std::string &name)
static void setupSimpleDefaultLogging(const bool use_prefix=true, const bool use_color_coding=true, const int message_limit=10)
static void addMessage(int64_t messageFlag, const std::string &message)
static std::shared_ptr< BackendType > getBackend(const std::string &name)
Definition: OpmLog.hpp:79
static void warning(const std::string &message)
static void bug(const std::string &message)
static std::shared_ptr< BackendType > popBackend(const std::string &name)
Definition: OpmLog.hpp:85
static void addTaggedMessage(int64_t messageFlag, const std::string &tag, const std::string &message)
static bool enabledMessageType(int64_t messageType)
Definition: A.hpp:4