CMS 3D CMS Logo

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