My Project
Loading...
Searching...
No Matches
OpmLog.hpp
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
26#include <opm/common/OpmLog/Logger.hpp>
27#include <opm/common/OpmLog/LogUtil.hpp>
28
29namespace Opm {
30
31 class LogBackend;
32#ifdef EMBEDDED_PYTHON
33 class PyRunModule;
34#endif
35
36/*
37 The OpmLog class is a fully static class which manages a proper
38 Logger instance.
39*/
40
41
42class OpmLog {
43
44public:
45 static void addMessage(int64_t messageFlag , const std::string& message);
46 static void addTaggedMessage(int64_t messageFlag, const std::string& tag, const std::string& message);
47
48 static void info(const std::string& message);
49 static void warning(const std::string& message);
50 static void error(const std::string& message);
51 static void problem(const std::string& message);
52 static void bug(const std::string& message);
53 static void debug(const std::string& message);
54 static void note(const std::string& message);
55
56 static void info(const std::string& tag, const std::string& message);
57 static void warning(const std::string& tag, const std::string& message);
58 static void error(const std::string& tag, const std::string& message);
59 static void problem(const std::string& tag, const std::string& message);
60 static void bug(const std::string& tag, const std::string& message);
61 static void debug(const std::string& tag, const std::string& message);
62 static void note(const std::string& tag, const std::string& message);
63
64 static bool hasBackend( const std::string& backendName );
65 static void addBackend(const std::string& name , std::shared_ptr<LogBackend> backend);
66 static bool removeBackend(const std::string& name);
67 static void removeAllBackends();
68 static bool enabledMessageType( int64_t messageType );
69 static void addMessageType( int64_t messageType , const std::string& prefix);
70
77 static void setupSimpleDefaultLogging(const bool use_prefix = true,
78 const bool use_color_coding = true,
79 const int message_limit = 10);
80
81 template <class BackendType>
82 static std::shared_ptr<BackendType> getBackend(const std::string& name) {
83 auto logger = getLogger();
84 return logger->getBackend<BackendType>(name);
85 }
86
87 template <class BackendType>
88 static std::shared_ptr<BackendType> popBackend(const std::string& name) {
89 auto logger = getLogger();
90 return logger->popBackend<BackendType>(name);
91 }
92
93
94 static bool stdoutIsTerminal();
95
110 static bool setLogger(std::shared_ptr<Logger> logger);
111
112private:
113#ifdef EMBEDDED_PYTHON
114 friend class PyRunModule;
115#endif
116 static std::shared_ptr<Logger> getLogger();
117 static std::shared_ptr<Logger> m_logger;
118};
119
120
121}
122
123
124
125
126#endif
Definition OpmLog.hpp:42
static void setupSimpleDefaultLogging(const bool use_prefix=true, const bool use_color_coding=true, const int message_limit=10)
Create a basic logging setup that will send all log messages to standard output.
Definition OpmLog.cpp:218
static bool setLogger(std::shared_ptr< Logger > logger)
Sets the global logger instance for the OpmLog class.
Definition OpmLog.cpp:56
This class implements a small container which holds the transmissibility mulitpliers for all the face...
Definition Exceptions.hpp:30