ATLAS Offline Software
Control
AthenaMonitoring
AthenaMonitoring
LogFileMsgStream.h
Go to the documentation of this file.
1
/*
2
Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration
3
*/
4
5
#ifndef LOGFILEMSGSTREAM_H
6
#define LOGFILEMSGSTREAM_H
7
8
// ********************************************************************
9
//
10
// NAME: LogFileMsgStream.H
11
//
12
// DESCRIPTION: class for piping output to logfile and MessageSvc
13
//
14
// AUTHOR: Rolf Seuster 27.10.2005: 1st implementation
15
//
16
// ********************************************************************
17
18
#include "GaudiKernel/MsgStream.h"
19
#include "GaudiKernel/Message.h"
20
21
#include <fstream>
22
#include <string>
23
24
class
LogFileMsgStream
:
public
MsgStream {
25
public
:
26
// constructor
27
LogFileMsgStream
(IMessageSvc*
svc
,
28
const
std::string&
source
,
29
const
std::string&
filename
,
30
bool
startlogging ) :
31
MsgStream(
svc
,
source
),
m_FormatString
(
""
)
32
{
33
if
(startlogging)
34
m_logfile
.open(
filename
.c_str(),
35
std::ofstream::out
| std::ofstream::app);
36
};
37
38
// destructor
39
~LogFileMsgStream
() {
40
if
(
m_logfile
.is_open())
41
m_logfile
.close();
42
};
43
45
// almost plain copy from MsgStream.h
46
LogFileMsgStream
&
operator<<
(
MSG::Level
level
) {
47
return
(
LogFileMsgStream
&)
MsgStream::report
(
level
);
48
}
49
51
// template <typename T>
52
// copied from MsgStream.h, doesn't work for all types (vectors)
53
// but that deficit doesn't harm
54
template
<
class
T>
55
MsgStream&
operator<<
(
const
T
&
arg
) {
56
if
(isActive()) m_stream <<
arg
;
57
return
*
this
;
58
}
59
60
// copied from MsgStream.cpp
61
// here we copy the output to a file as well
62
MsgStream&
doOutput
() {
63
Message
msg
(m_source,m_currLevel,m_stream.str());
64
if
(
m_FormatString
!=
""
)
65
msg
.setFormat(
m_FormatString
);
66
if
(
m_logfile
.is_open())
67
m_logfile
<<
msg
<<
"\n"
;
68
return
MsgStream::doOutput();
69
}
70
71
void
setFormat
(
const
std::string&
str
) {
72
m_FormatString
=
str
;
73
}
74
75
private
:
76
// default constructor, unusable !
77
LogFileMsgStream
();
78
79
std::ofstream
m_logfile
;
80
81
std::string
m_FormatString
;
82
83
};
84
85
#endif
LogFileMsgStream
Definition:
LogFileMsgStream.h:24
LogFileMsgStream::~LogFileMsgStream
~LogFileMsgStream()
Definition:
LogFileMsgStream.h:39
python.AthDsoLogger.out
out
Definition:
AthDsoLogger.py:71
LogFileMsgStream::LogFileMsgStream
LogFileMsgStream(IMessageSvc *svc, const std::string &source, const std::string &filename, bool startlogging)
Definition:
LogFileMsgStream.h:27
checkTP.report
report
Definition:
checkTP.py:127
LogFileMsgStream::doOutput
MsgStream & doOutput()
Definition:
LogFileMsgStream.h:62
python.iconfTool.models.loaders.level
level
Definition:
loaders.py:20
TrigConf::MSGTC::Level
Level
Definition:
Trigger/TrigConfiguration/TrigConfBase/TrigConfBase/MsgStream.h:21
LogFileMsgStream::operator<<
LogFileMsgStream & operator<<(MSG::Level level)
Accept MsgStream activation using MsgStreamer operator.
Definition:
LogFileMsgStream.h:46
Handler::svc
AthROOTErrorHandlerSvc * svc
Definition:
AthROOTErrorHandlerSvc.cxx:10
LogFileMsgStream::LogFileMsgStream
LogFileMsgStream()
create_dcsc_inputs_sqlite.arg
list arg
Definition:
create_dcsc_inputs_sqlite.py:48
python.CaloScaleNoiseConfig.str
str
Definition:
CaloScaleNoiseConfig.py:78
LogFileMsgStream::m_FormatString
std::string m_FormatString
Definition:
LogFileMsgStream.h:81
CaloCellTimeCorrFiller.filename
filename
Definition:
CaloCellTimeCorrFiller.py:24
LogFileMsgStream::m_logfile
std::ofstream m_logfile
Definition:
LogFileMsgStream.h:79
copySelective.source
string source
Definition:
copySelective.py:32
str
Definition:
BTagTrackIpAccessor.cxx:11
python.AutoConfigFlags.msg
msg
Definition:
AutoConfigFlags.py:7
run.Message
Message
Definition:
run.py:57
TSU::T
unsigned long long T
Definition:
L1TopoDataTypes.h:35
LogFileMsgStream::setFormat
void setFormat(const std::string &str)
Definition:
LogFileMsgStream.h:71
Generated on Wed Jan 8 2025 21:13:10 for ATLAS Offline Software by
1.8.18