11 #ifndef BEMBEL_SRC_IO_LOGGER_HPP_
12 #define BEMBEL_SRC_IO_LOGGER_HPP_
30 std::string _sep =
" ";
32 std::ios_base::openmode _mode = std::fstream::trunc;
33 std::string name_ =
"default.log";
37 explicit Logger(std::string name) { name_ = name; }
38 Logger(std::string name, std::string sep) {
42 Logger(std::string name, std::string sep, std::ios_base::openmode mode) {
47 Logger(std::string name, std::ios_base::openmode mode) {
51 explicit Logger(std::ios_base::openmode mode) { _mode = mode; }
52 template <
typename T,
typename... Args>
53 void term(T t, Args... arg) {
54 std::cout << std::setprecision(N - 4) << std::setw(N + _sep.size())
55 << std::left << t << _sep;
60 std::cout << std::setprecision(N - 4) << std::setw(N + _sep.size()) << t
63 template <
typename T,
typename... Args>
64 void file(T t, Args... arg) {
65 if (!(_file.is_open())) {
66 _file.open(name_, std::fstream::out | std::fstream::trunc);
68 _file << std::setprecision(N - 4) << std::setw(N + _sep.size()) << std::left
74 if (!(_file.is_open())) {
75 _file.open(name_, std::fstream::out | std::fstream::trunc);
78 _file << std::setprecision(N - 4) << std::setw(N + _sep.size()) << std::left
81 template <
typename... Args>
82 void both(Args... arg) {
86 ~
Logger() { _file.close(); }
A simple class for producing output.
Routines for the evalutation of pointwise errors.