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