EEROS  1.0.0.0
API for the EEROS Real-Time Robotics Framework
LogEntry.hpp
Go to the documentation of this file.
1 #ifndef ORG_EEROS_LOGGER_LOGENTRY_HPP_
2 #define ORG_EEROS_LOGGER_LOGENTRY_HPP_
4 
5 namespace eeros {
6  namespace logger {
7 
8  class LogEntry {
9  public:
10  LogEntry(LogWriter* writer, LogLevel level, unsigned category = 0) : w(writer) {
11  if(w != nullptr) w->begin(os, level, category);
12  }
13  LogEntry(const LogEntry&);
14 
15  virtual ~LogEntry() {
16  if(w != nullptr) w->end(os);
17  }
18 
19  template <typename T>
20  LogEntry& operator<<(T value) {
21  os << value;
22  return *this;
23  }
24 
25  LogEntry& operator<<(void (*f)(LogWriter&) ) {
26  w->endl(os);
27  return *this;
28  }
29  private:
30  LogWriter* w;
31  std::ostringstream os;
32  };
33 
34  }
35 }
36 
37 #endif /* ORG_EEROS_LOGGER_LOGENTRY_HPP_ */
virtual void begin(std::ostringstream &os, LogLevel level, unsigned category)=0
virtual void end(std::ostringstream &os)=0
Definition: Config.hpp:14
LogEntry(LogWriter *writer, LogLevel level, unsigned category=0)
Definition: LogEntry.hpp:10
Definition: LogEntry.hpp:8
virtual ~LogEntry()
Definition: LogEntry.hpp:15
virtual void endl(std::ostringstream &os)=0
LogEntry & operator<<(T value)
Definition: LogEntry.hpp:20
Definition: LogWriter.hpp:10
LogLevel
Definition: Logger.hpp:13
LogEntry & operator<<(void(*f)(LogWriter &))
Definition: LogEntry.hpp:25