test
CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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
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::LogVerbatim("G4cout") << addThreadPrefix(m_threadPrefix, trim(coutString));
29  return 0;
30 }
31 
32 G4int CustomUIsessionThreadPrefix::ReceiveG4cerr(const G4String& cerrString)
33 {
34  edm::LogWarning("G4cerr") << addThreadPrefix(m_threadPrefix, trim(cerrString));
35  return 0;
36 }
G4int ReceiveG4cout(const G4String &coutString) override
G4int ReceiveG4cerr(const G4String &cerrString) override
uint16_t size_type
std::string trim(const std::string &str)
std::string to_string(const T &t)
Definition: Logger.cc:26
#define end
Definition: vmac.h:37
CustomUIsessionThreadPrefix(const std::string &threadPrefix, int threadId)