| # Gaudi Framework, version v25r0 |

Home |  | Generated: Mon Feb 17 2014

- Main Page
- Related Pages
- Modules
- Namespaces
- Classes
- Files

- File List
- File Members

All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
StreamLogger.cpp
Go to the documentation of this file.
1 #include "StreamLogger.h"
2
3 #include "GaudiKernel/IMessageSvc.h"
4
5 #include <stdexcept>
6 #include <fstream>
7
8 // StreamLogger::StreamLogger(): m_isMine(0), p_ost(0), p_msgStr(0), m_level(0){};
9
10 StreamLogger::StreamLogger(const std::string& file): m_isMine(1),
11 p_ost(0), p_msgStr(0) {
12 m_name = "file:" + file;
13 p_ost = new std::ofstream(file.c_str());
14 if (p_ost == 0) {
15 throw std::invalid_argument("can't open file");
16 }
17 }
18
19 StreamLogger::StreamLogger(IMessageSvc *svc, MSG::Level lev):
20 m_isMine(1), p_ost(0), p_msgStr(0) {
21 p_msgStr = new MsgStream( svc, "IssueLogger");
22 m_level = lev;
23 m_name = "MsgStream";
24 }
25
26 StreamLogger::StreamLogger(std::ostream& ost): m_isMine(0) , p_ost(0),
27 p_msgStr(0){
28 p_ost = &ost;
29 if (ost == std::cerr) {
30 m_name = "STDERR";
31 } else if ( ost == std::cout) {
32 m_name = "STDOUT";
33 } else {
34 m_name = "unknown ostream";
35 }
36 }
37
38 std::string
39 StreamLogger::name() const {
40 return m_name;
41 }
42
43 StreamLogger::~StreamLogger() {
44 if (m_isMine && p_ost != 0) {
45 delete p_ost;
46 }
47 if (p_msgStr != 0) {
48 delete p_msgStr;
49 }
50 }