LDMX Software
SimCore
src
SimCore
G4Session.cxx
Go to the documentation of this file.
1
7
#include "
SimCore/G4Session.h
"
8
9
#include "Framework/Exception/Exception.h"
10
11
namespace
simcore {
12
13
LoggedSession::LoggedSession
(
const
std::string& coutFileName,
14
const
std::string& cerrFileName) {
15
coutFile_
.open(coutFileName);
16
if
(not
coutFile_
.is_open()) {
17
EXCEPTION_RAISE(
"G4Logging"
,
18
"Unable to open log file '"
+ coutFileName +
"'."
);
19
}
20
21
cerrFile_
.open(cerrFileName);
22
if
(not
cerrFile_
.is_open()) {
23
EXCEPTION_RAISE(
"G4Logging"
,
24
"Unable to open log file '"
+ cerrFileName +
"'."
);
25
}
26
}
27
28
LoggedSession::~LoggedSession
() {
29
coutFile_
.close();
30
cerrFile_
.close();
31
}
32
33
G4int
LoggedSession::ReceiveG4cout
(
const
G4String& message) {
34
coutFile_
<< message;
35
coutFile_
.flush();
36
return
0;
// 0 return value == sucess
37
}
38
39
G4int
LoggedSession::ReceiveG4cerr
(
const
G4String& message) {
40
cerrFile_
<< message;
41
cerrFile_
.flush();
42
return
0;
// 0 return value == sucess
43
}
44
}
// namespace simcore
G4Session.h
Classes which redirect the output of G4cout and G4cerr.
simcore::LoggedSession::cerrFile_
std::ofstream cerrFile_
cerr log file
Definition
G4Session.h:62
simcore::LoggedSession::~LoggedSession
~LoggedSession()
Destructor.
Definition
G4Session.cxx:28
simcore::LoggedSession::ReceiveG4cerr
G4int ReceiveG4cerr(const G4String &message)
Redirects cerr to file.
Definition
G4Session.cxx:39
simcore::LoggedSession::coutFile_
std::ofstream coutFile_
cout log file
Definition
G4Session.h:59
simcore::LoggedSession::LoggedSession
LoggedSession(const std::string &coutFileName="G4cout.log", const std::string &cerrFileName="G4cerr.log")
Constructor.
Definition
G4Session.cxx:13
simcore::LoggedSession::ReceiveG4cout
G4int ReceiveG4cout(const G4String &message)
Redirects cout to file.
Definition
G4Session.cxx:33
Generated by
1.9.8