Eris  1.3.21
LogStream.h
1 #ifndef ERIS_LOGSTREAM_H
2 #define ERIS_LOGSTREAM_H
3 
4 #include <Eris/Log.h>
5 
6 #include <Atlas/Objects/ObjectsFwd.h>
7 
8 #include <sstream>
9 
10 namespace Atlas {
11  namespace Message {
12  class Element;
13  }
14 }
15 
16 namespace Eris
17 {
18 
19 void doLog(LogLevel lvl, const std::string& msg);
20 
22 {
23 public:
24  std::ostream& operator<<(const std::string& s)
25  {
26  return m_stream << s;
27  }
28 
29 
30 protected:
31 
32  std::ostringstream m_stream;
33 };
34 
35 class debug : public logStreamBase
36 {
37 public:
38  ~debug()
39  {
40  m_stream << std::flush;
41  doLog(LOG_DEBUG, m_stream.str());
42  }
43 };
44 
45 class warning : public logStreamBase
46 {
47 public:
48  ~warning()
49  {
50  m_stream << std::flush;
51  doLog(LOG_WARNING, m_stream.str());
52  }
53 };
54 
55 class error : public logStreamBase
56 {
57 public:
58  ~error()
59  {
60  m_stream << std::flush;
61  doLog(LOG_ERROR, m_stream.str());
62  }
63 };
64 
65 std::ostream& operator<<(std::ostream& s, const Atlas::Objects::Root& obj);
66 std::ostream& operator<<(std::ostream& s, const Atlas::Message::Element& msg);
67 
68 } // of namespace Eris
69 
70 #endif