LDMX Software
G4Session.cxx
1#include "SimCore/G4Session.h"
2
3#include <algorithm>
4
5namespace simcore {
6
7LoggedSession::LoggedSession(std::string logging_prefix)
8 : the_log_{::framework::logging::makeLogger(logging_prefix)} {}
9
10G4int LoggedSession::ReceiveG4cout(const G4String& msg) {
11 std::string message = msg;
12 std::transform(message.begin(), message.end(), message.begin(), ::toupper);
13
14 if (message.find("WARNING") != std::string::npos) {
15 ldmx_log(warn) << msg;
16 } else if (message.find("ERROR") != std::string::npos) {
17 ldmx_log(error) << msg;
18 } else {
19 ldmx_log(debug) << msg;
20 }
21
22 return 0;
23}
24
25G4int LoggedSession::ReceiveG4cerr(const G4String& msg) {
26 std::string message = msg;
27 std::transform(message.begin(), message.end(), message.begin(), ::toupper);
28
29 if (message.find("ERROR") != std::string::npos ||
30 message.find("FATAL") != std::string::npos) {
31 ldmx_log(error) << msg;
32 } else {
33 ldmx_log(debug) << msg;
34 }
35
36 return 0;
37}
38
39} // namespace simcore
Classes which redirect the output of G4cout and G4cerr.
LoggedSession(std::string logging_prefix="Geant4")
Constructor - creates a logger named "Geant4".
Definition G4Session.cxx:7
G4int ReceiveG4cout(const G4String &message) override
Receive a message from G4cout.
Definition G4Session.cxx:10
G4int ReceiveG4cerr(const G4String &message) override
Receive a message from G4cerr.
Definition G4Session.cxx:25
All classes in the ldmx-sw project use this namespace.
Dynamically loadable photonuclear models either from SimCore or external libraries implementing this ...