CMS 3D CMS Logo

CustomUIsessionThreadPrefix.cc
Go to the documentation of this file.
2 
5  m_threadPrefix(threadPrefix+std::to_string(threadId)+">> ")
6 {}
7 
9 
10 namespace {
11  std::string addThreadPrefix(const std::string& threadPrefix, const std::string str) {
12  // Add thread prefix to each line beginning
13  std::string ret;
14  std::string::size_type beg = 0;
15  std::string::size_type end = str.find('\n');
16  while(end != std::string::npos) {
17  ret += threadPrefix + str.substr(beg, end-beg) + "\n";
18  beg = end+1;
19  end = str.find('\n', beg);
20  }
21  ret += threadPrefix + str.substr(beg, end);
22  return ret;
23  }
24 }
25 
26 G4int CustomUIsessionThreadPrefix::ReceiveG4cout(const G4String& coutString)
27 {
28  // edm::LogInfo("G4cout") << addThreadPrefix(m_threadPrefix, trim(coutString));
29  edm::LogVerbatim("G4cout") << addThreadPrefix(m_threadPrefix, trim(coutString));
30  return 0;
31 }
32 
33 G4int CustomUIsessionThreadPrefix::ReceiveG4cerr(const G4String& cerrString)
34 {
35  edm::LogWarning("G4cerr") << addThreadPrefix(m_threadPrefix, trim(cerrString));
36  return 0;
37 }
G4int ReceiveG4cout(const G4String &coutString) override
G4int ReceiveG4cerr(const G4String &cerrString) override
uint16_t size_type
std::string trim(const std::string &str)
#define end
Definition: vmac.h:39
#define str(s)
CustomUIsessionThreadPrefix(const std::string &threadPrefix, int threadId)