StreamLogger.h
Go to the documentation of this file.
1 #ifndef GAUDISVC_STREAMLOGGER_H
2 #define GAUDISVC_STREAMLOGGER_H
3 
5 
6 #include <ostream>
7 #include <string>
8 
9 class IMessageSvc;
10 
11 class StreamLogger final {
12 public:
13  StreamLogger(const std::string& file);
16 
17  const std::string& name() const { return m_name; }
18 
19  void WriteToStream(const std::string& str) { *m_ost << str << std::endl; }
20  void WriteToMsgSvc(const std::string& str) { *m_msgStr << m_level << str << endmsg; }
21 
22 private:
25  std::ostream* m_ost = nullptr;
28 };
29 
30 #endif
std::unique_ptr< MsgStream > m_msgStr
Definition: StreamLogger.h:26
T endl(T...args)
StreamLogger(const std::string &file)
Definition: StreamLogger.cpp:4
const std::string & name() const
Definition: StreamLogger.h:17
std::string m_name
Definition: StreamLogger.h:23
STL class.
The IMessage is the interface implemented by the message service.
Definition: IMessageSvc.h:57
void WriteToMsgSvc(const std::string &str)
Definition: StreamLogger.h:20
std::unique_ptr< std::ostream > m_oost
Definition: StreamLogger.h:24
STL class.
void WriteToStream(const std::string &str)
Definition: StreamLogger.h:19
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:244
MSG::Level m_level
Definition: StreamLogger.h:27
std::ostream * m_ost
Definition: StreamLogger.h:25