GEGELATI
logger.h
1
37#ifndef LOGGER_H
38#define LOGGER_H
39
40#include <iostream>
41
42namespace 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
Definition: logger.h:48
Logger operator<<(const T &val)
<< operator allowing to log elements that ostream actually accepts (char, int...).
Definition: logger.h:85
Logger operator<<(std::ostream &(*manip)(std::ostream &))
<< operator to manipulate stream and enter stream-specific elements (like std::endl).
Definition: logger.cpp:41
virtual ~Logger()=default
Virtual default destructor for polyphormism support.
Logger(std::ostream &out=std::cout)
Constructor initializing a specific output. Default is cout.
Definition: logger.h:61
Definition: laBasicLogger.h:44