Sapphire++
 v1.3.0-121-g2682132
Loading...
Searching...
No Matches
sapphirepp-logstream.h
Go to the documentation of this file.
1// -----------------------------------------------------------------------------
2//
3// Copyright (C) 2023 by the Sapphire++ authors
4//
5// This file is part of Sapphire++.
6//
7// Sapphire++ is free software: you can redistribute it and/or modify it under
8// the terms of the GNU Lesser General Public License as published by the Free
9// Software Foundation, either version 3 of the License, or (at your option) any
10// later version.
11//
12// Sapphire++ is distributed in the hope that it will be useful, but WITHOUT ANY
13// WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
14// A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
15// details.
16//
17// You should have received a copy of the GNU Lesser General Public License
18// along with Sapphire++. If not, see <https://www.gnu.org/licenses/>.
19//
20// -----------------------------------------------------------------------------
21
28
29#ifndef UTILS_SAPPHIREPPLOGSTREAM_H
30#define UTILS_SAPPHIREPPLOGSTREAM_H
31
32#include <deal.II/base/conditional_ostream.h>
33#include <deal.II/base/exceptions.h>
34#include <deal.II/base/logstream.h>
35
36#include <exception>
37#include <fstream>
38#include <string>
39
44namespace sapphirepp
45{
46
54 namespace Utils
55 {
56
66 class SapphireppLogStream : public dealii::LogStream
67 {
68 public:
71
72
75
76
92 void
93 init(const unsigned int depth_console = 2,
94 const bool enable_mpi_output = false);
95
96
106 void
107 init(const int argc, const char *const argv[]);
108
109
110
122 void
123 init_parse(const int argc,
124 const char *const argv[],
125 std::string &parameter_filename,
126 bool &resume);
127
128
129
137 void
138 attach_file(const std::string &filepath,
139 const unsigned int depth_file,
140 const bool enable_mpi_output = false);
141
142
151 void
152 print_error(const std::exception &exc);
153
154
162 void
163 print_warning(const std::string &warning);
164
165
172 unsigned int
174
180 unsigned int
183
184
196 std::ostream &
197 to_ostream(const unsigned int verbosity = 3);
198
209 dealii::ConditionalOStream
210 to_condition_ostream(const unsigned int verbosity = 3);
211
213 operator std::ostream &();
214
216 operator dealii::ConditionalOStream();
218
219
220
221 private:
223 std::ofstream log_file;
224 };
225
226 } // namespace Utils
227
233} // namespace sapphirepp
234#endif
LogStream for Sapphire+⁠+
Definition sapphirepp-logstream.h:67
void attach_file(const std::string &filepath, const unsigned int depth_file, const bool enable_mpi_output=false)
Attach a logfile to the stream.
Definition sapphirepp-logstream.cpp:276
SapphireppLogStream()
Constructor.
Definition sapphirepp-logstream.cpp:50
void init(const unsigned int depth_console=2, const bool enable_mpi_output=false)
Initialize the log stream.
Definition sapphirepp-logstream.cpp:76
void print_warning(const std::string &warning)
Prints a warning to std:err and this LogStream.
Definition sapphirepp-logstream.cpp:332
void print_error(const std::exception &exc)
Prints an error message to std:err and this LogStream.
Definition sapphirepp-logstream.cpp:305
dealii::ConditionalOStream to_condition_ostream(const unsigned int verbosity=3)
Conversion to ConditionalOStream.
Definition sapphirepp-logstream.cpp:389
~SapphireppLogStream()
Destructor.
Definition sapphirepp-logstream.cpp:59
std::ostream & to_ostream(const unsigned int verbosity=3)
Conversion to std::ostream.
Definition sapphirepp-logstream.cpp:373
unsigned int get_verbosity_console()
Get the verbosity of the console output.
Definition sapphirepp-logstream.cpp:353
unsigned int get_verbosity_file()
Get the verbosity of the file output.
Definition sapphirepp-logstream.cpp:363
void init_parse(const int argc, const char *const argv[], std::string &parameter_filename, bool &resume)
Initialize the log stream and parse command line options.
Definition sapphirepp-logstream.cpp:181
Namespace for utility functions.
Definition grid-data-function.h:42
Namespace for Sapphire+⁠+.
Definition config.h:51
sapphirepp::Utils::SapphireppLogStream saplog
The standard log stream for Sapphire+⁠+.
Definition sapphirepp-logstream.cpp:46