HCE project C++ developers source code library  1.1.1
HCE project developer library
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
LoggerStream.hpp
Go to the documentation of this file.
1 
14 #ifndef LOGGER_STREAM_HPP
15 #define LOGGER_STREAM_HPP
16 
17 #include <functional>
18 #include <iostream>
19 #include <sstream>
20 #include <typeinfo>
21 
22 namespace HCE
23 {
24 //-----------------------------------------------------------------------------
25 typedef std::function<std::string(const std::string&)> Loggable;
26 //-----------------------------------------------------------------------------
27 class LoggerStream : public std::ostream
28 {
29 public:
30  LoggerStream(void);
31  virtual ~LoggerStream(void);
32 
33  void resetLogStream(void);
34  void setLogStream(std::ostream& os_);
35  std::string logMsg(bool isReset=true);
36  std::ostream& log(void) {return *this;}
37 
38  void setLoggable(Loggable loggable_);
39  void resetLoggable(void);
40  std::ostream& put(const std::string&);
41  LoggerStream& endl(void);
42 private:
43  std::stringbuf logBuf;
44  std::basic_streambuf<char>* pBuf;
45 
46  Loggable loggable;
47 
48  typedef std::ostream inherited;
49 };
50 //-----------------------------------------------------------------------------
51 //-----------------------------------------------------------------------------
52 std::ostream& endl(std::ostream& os);
53 LoggerStream& operator<<(LoggerStream& os, const std::string& rhs);
54 LoggerStream& operator<<(LoggerStream& os, const char* rhs);
55 //-----------------------------------------------------------------------------
56 //-----------------------------------------------------------------------------
57 
58 } // end namespace HCE
59 
60 #endif // LOGGER_STREAM_HPP