iterative-solver 0.0
Logger.h
1#ifndef LINEARALGEBRA_SRC_MOLPRO_LINALG_ITSOLV_LOGGER_H
2#define LINEARALGEBRA_SRC_MOLPRO_LINALG_ITSOLV_LOGGER_H
3#include <bitset>
4#include <iomanip>
5#include <iterator>
6#include <numeric>
7#include <ostream>
8#include <sstream>
9#include <string>
10
11namespace molpro::linalg::itsolv {
12
40struct Logger {
49 enum Level : short { None, Trace, Debug, Info, Warn, Error, Fatal };
50
51 void msg(const std::string& message, Level log_lvl);
52
53 template <typename ForwardIt>
54 void msg(const std::string& message, ForwardIt begin, ForwardIt end, Level log_lvl, int precision = 3) {
55 std::ostringstream os{};
56 os << message;
57 if (!std::is_integral_v<decltype(*begin)>) {
58 os << std::setprecision(precision);
59 }
60 std::copy(begin, end, std::ostream_iterator<decltype(*begin)>(os, ", "));
61 msg(os.str(), log_lvl);
62 }
63
65 static std::string scientific(double val);
66
69 bool data_dump = false;
70};
71
72} // namespace molpro::linalg::itsolv
73
74#endif // LINEARALGEBRA_SRC_MOLPRO_LINALG_ITSOLV_LOGGER_H
4-parameter interpolation of a 1-dimensional function given two points for which function values and ...
Definition: helper.h:10
A dummy structured logger.
Definition: Logger.h:40
void msg(const std::string &message, Level log_lvl)
Definition: Logger.cpp:16
bool data_dump
highest level of warning/error that can be logged
Definition: Logger.h:69
static std::string scientific(double val)
Converts double to a string in scientific notation.
Definition: Logger.cpp:33
void msg(const std::string &message, ForwardIt begin, ForwardIt end, Level log_lvl, int precision=3)
Definition: Logger.h:54
Level
Different levels of logging.
Definition: Logger.h:49
@ Info
Definition: Logger.h:49
@ Trace
Definition: Logger.h:49
@ Fatal
Definition: Logger.h:49
@ None
Definition: Logger.h:49
@ Error
Definition: Logger.h:49
@ Debug
Definition: Logger.h:49
@ Warn
Definition: Logger.h:49
Level max_trace_level
Definition: Logger.h:67
Level max_warn_level
highest level of trace message that can be logged
Definition: Logger.h:68