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 namespace Opm {
29 
30 
31 /*
32  The OpmLog class is a fully static class which manages a proper
33  Logger instance.
34 */
35 
36 
37 class OpmLog {
38 public:
39  static void addMessage(int64_t messageFlag , const std::string& message);
40 
41  static bool hasBackend( const std::string& backendName );
42  static void addBackend(const std::string& name , std::shared_ptr<LogBackend> backend);
43  static bool removeBackend(const std::string& name);
44  static bool enabledMessageType( int64_t messageType );
45  static void addMessageType( int64_t messageType , const std::string& prefix);
46 
47  template <class BackendType>
48  static std::shared_ptr<BackendType> getBackend(const std::string& name) {
49  auto logger = OpmLog::getLogger();
50  return logger->getBackend<BackendType>(name);
51  }
52 
53  template <class BackendType>
54  static std::shared_ptr<BackendType> popBackend(const std::string& name) {
55  auto logger = OpmLog::getLogger();
56  return logger->popBackend<BackendType>(name);
57  }
58 
59 
60 private:
61  static std::shared_ptr<Logger> getLogger();
62  static std::shared_ptr<Logger> m_logger;
63 };
64 
65 
66 }
67 
68 
69 
70 
71 #endif
static void addMessageType(int64_t messageType, const std::string &prefix)
static bool hasBackend(const std::string &backendName)
static bool enabledMessageType(int64_t messageType)
Definition: Deck.hpp:29
static std::shared_ptr< BackendType > getBackend(const std::string &name)
Definition: OpmLog.hpp:48
static void addBackend(const std::string &name, std::shared_ptr< LogBackend > backend)
static std::shared_ptr< BackendType > popBackend(const std::string &name)
Definition: OpmLog.hpp:54
static void addMessage(int64_t messageFlag, const std::string &message)
Definition: OpmLog.hpp:37
static bool removeBackend(const std::string &name)