GEGELATI

Loading...
Searching...
No Matches
logger.h
1
37#ifndef LOGGER_H
38#define LOGGER_H
39
40#include <iostream>
41
42 namespace Log {
43
47 class Logger
48 {
49 private:
53 std::ostream* out;
54
55 public:
61 explicit Logger(std::ostream& out = std::cout) : out(&out){};
62
64 virtual ~Logger() = default;
65
74 Logger operator<<(std::ostream& (*manip)(std::ostream&));
75
85 template <typename T> Logger operator<<(const T& val)
86 {
87 *out << val;
88
89 // flushes the buffer, useful especially with ofstream where without
90 // that, nothing will be printed until close
91 out->flush();
92
93 return *this;
94 }
95 };
96} // namespace Log
97#endif
Log::Logger
Definition logger.h:48
Log::Logger::operator<<
Logger operator<<(const T &val)
<< operator allowing to log elements that ostream actually accepts (char, int...).
Definition logger.h:85
Log::Logger::operator<<
Logger operator<<(std::ostream &(*manip)(std::ostream &))
<< operator to manipulate stream and enter stream-specific elements (like std::endl).
Definition logger.cpp:41
Log::Logger::~Logger
virtual ~Logger()=default
Virtual default destructor for polyphormism support.
Log::Logger::Logger
Logger(std::ostream &out=std::cout)
Constructor initializing a specific output. Default is cout.
Definition logger.h:61
Log
Definition cycleDetectionLALogger.h:38