My Project
DeferredLogger.hpp
1 /*
2  Copyright 2018 SINTEF Digital, Mathematics and Cybernetics.
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 
21 #ifndef OPM_DEFERREDLOGGER_HEADER_INCLUDED
22 #define OPM_DEFERREDLOGGER_HEADER_INCLUDED
23 
24 #include <opm/simulators/utils/ParallelCommunication.hpp>
25 
26 #include <string>
27 #include <vector>
28 
29 namespace Opm
30 {
36 namespace ExceptionType
37 {
38 
39 
40 /*
41  If an exception has been raised on more than processor simultaneously the
42  highest number type will be thrown in the subsequent global rethrow.
43 */
44 
45 enum ExcEnum {
46  NONE = 0,
47  RUNTIME_ERROR = 1,
48  INVALID_ARGUMENT = 2,
49  LOGIC_ERROR = 3,
50  DEFAULT = 4, // will throw std::logic_error()
51  NUMERICAL_ISSUE = 5
52 };
53 }
54 
55 
57  {
58  public:
59 
60  struct Message
61  {
62  int64_t flag;
63  std::string tag;
64  std::string text;
65  };
66 
67  void info(const std::string& tag, const std::string& message);
68  void warning(const std::string& tag, const std::string& message);
69  void error(const std::string& tag, const std::string& message);
70  void problem(const std::string& tag, const std::string& message);
71  void bug(const std::string& tag, const std::string& message);
72  void debug(const std::string& tag, const std::string& message);
73  void note(const std::string& tag, const std::string& message);
74 
75  void info(const std::string& message);
76  void warning(const std::string& message);
77  void error(const std::string& message);
78  void problem(const std::string& message);
79  void bug(const std::string& message);
80  void debug(const std::string& message);
81  void note(const std::string& message);
82 
85  void logMessages();
86 
88  void clearMessages();
89 
90  private:
91  std::vector<Message> messages_;
92  friend DeferredLogger gatherDeferredLogger(const DeferredLogger& local_deferredlogger,
93  Parallel::Communication mpi_communicator);
94  };
95 
96 } // namespace Opm
97 
98 #endif // OPM_DEFERREDLOGGER_HEADER_INCLUDED
Definition: DeferredLogger.hpp:57
void logMessages()
Log all messages to the OpmLog backends, and clear the message container.
Definition: DeferredLogger.cpp:85
void clearMessages()
Clear the message container without logging them.
Definition: DeferredLogger.cpp:93
friend DeferredLogger gatherDeferredLogger(const DeferredLogger &local_deferredlogger, Parallel::Communication mpi_communicator)
Create a global log combining local logs.
Definition: gatherDeferredLogger.cpp:168
This file contains a set of helper functions used by VFPProd / VFPInj.
Definition: BlackoilPhases.hpp:26
Definition: DeferredLogger.hpp:61