12 std::ofstream output_file;
14 int logging_level = 1;
16 int current_level = 0;
26 logger_class(std::ostream stream) : output(NULL) { output.rdbuf(stream.rdbuf()); }
30 if (output_file.is_open()) {
48 output.rdbuf(stream.rdbuf());
49 if (output_file.is_open()) {
56 if (output_file.is_open()) {
59 output_file.open(filename, std::ios::out);
60 output.rdbuf(output_file.rdbuf());
64 template <
typename T>
void log(T text) {
66 if (current_level < logging_level) {
79 if (logger.current_level < logger.logging_level) {
std::ostream & operator<<(std::ostream &strm, const Array< n, m, T > &A)
Stream operator.
Define the logger class here.
logger_class(std::string filename)
Construct with filename.
void set_output(std::string filename)
Open stream to a file. Interprets strings as filenames.
void set_output(std::ostream stream)
Set the output stream.
void log(T text)
Log function.
friend logger_class & operator<<(logger_class &logger, T rhs)
logger_class(std::ostream stream)
Construct with stream.
logger_class()
Constructor without parameters, set the logger to std::out.
void set_verbosity(int level)
Set logging level.
~logger_class()
Close the file in the destructor.
int myrank()
rank of this node