Finite Volume Solver  prototype
A framework to build finite volume solvers for the AG Klein at the Freie Universität Berlin.
Log.hpp
Go to the documentation of this file.
1 // Copyright (c) 2019 Maikel Nadolski
2 //
3 // Permission is hereby granted, free of charge, to any person obtaining a copy
4 // of this software and associated documentation files (the "Software"), to deal
5 // in the Software without restriction, including without limitation the rights
6 // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7 // copies of the Software, and to permit persons to whom the Software is
8 // furnished to do so, subject to the following conditions:
9 //
10 // The above copyright notice and this permission notice shall be included in
11 // all copies or substantial portions of the Software.
12 //
13 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14 // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15 // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16 // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17 // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18 // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
19 // SOFTWARE.
20 
21 #ifndef FUB_EXT_BOOST_LOG_HPP
22 #define FUB_EXT_BOOST_LOG_HPP
23 
24 #include "fub/Duration.hpp"
25 #include <boost/log/common.hpp>
26 #include <boost/log/expressions.hpp>
27 #include <boost/log/trivial.hpp>
28 #include <boost/program_options.hpp>
29 #include <mpi.h>
30 
31 namespace fub {
32 
33 struct LogOptions {
34  LogOptions() = default;
35  LogOptions(const boost::program_options::variables_map& vm);
36 
37  static boost::program_options::options_description GetCommandLineOptions();
38 
39  std::string file_template{"{rank:04d}.log"};
40  std::vector<int> which_mpi_ranks_do_log{0};
41 };
42 
43 void InitializeLogging(MPI_Comm comm, const LogOptions& log = {});
44 
46  boost::log::sources::severity_logger<boost::log::trivial::severity_level>;
47 
49  return SeverityLogger(boost::log::keywords::severity =
50  boost::log::trivial::info);
51 }
52 
53 inline SeverityLogger GetLogger(boost::log::trivial::severity_level level) {
54  return SeverityLogger(boost::log::keywords::severity = level);
55 }
56 
57 void Log(std::string message, Duration timepoint,
58  boost::log::trivial::severity_level level =
59  boost::log::trivial::severity_level::info);
60 
61 } // namespace fub
62 
63 #endif // FINITEVOLUMESOLVER_LOG_HPP
The fub namespace.
Definition: AnyBoundaryCondition.hpp:31
void Log(std::string message, Duration timepoint, boost::log::trivial::severity_level level=boost::log::trivial::severity_level::info)
std::chrono::duration< double > Duration
Definition: Duration.hpp:31
SeverityLogger GetLogger(boost::log::trivial::severity_level level)
Definition: Log.hpp:53
boost::log::sources::severity_logger< boost::log::trivial::severity_level > SeverityLogger
Definition: Log.hpp:46
SeverityLogger GetInfoLogger()
Definition: Log.hpp:48
void InitializeLogging(MPI_Comm comm, const LogOptions &log={})
Definition: Log.hpp:33
LogOptions(const boost::program_options::variables_map &vm)
std::string file_template
Definition: Log.hpp:39
static boost::program_options::options_description GetCommandLineOptions()
std::vector< int > which_mpi_ranks_do_log
Definition: Log.hpp:40
LogOptions()=default