CMS 3D CMS Logo

List of all members | Public Member Functions | Private Attributes
CustomUIsessionThreadPrefix Class Reference

#include <CustomUIsessionThreadPrefix.h>

Inheritance diagram for CustomUIsessionThreadPrefix:
CustomUIsession

Public Member Functions

 CustomUIsessionThreadPrefix (const std::string &threadPrefix, int threadId)
 
G4int ReceiveG4cerr (const G4String &cerrString) override
 
G4int ReceiveG4cout (const G4String &coutString) override
 
 ~CustomUIsessionThreadPrefix () override
 
- Public Member Functions inherited from CustomUIsession
 CustomUIsession ()
 
G4int ReceiveG4cerr (const G4String &cerrString) override
 
G4int ReceiveG4cout (const G4String &coutString) override
 
void sendToFile (std::ofstream *)
 
void stopSendToFile ()
 
 ~CustomUIsession () override
 

Private Attributes

const std::string m_threadPrefix
 

Additional Inherited Members

- Protected Member Functions inherited from CustomUIsession
std::string trim (const std::string &str)
 

Detailed Description

This class is intended for debugging of multithreaded simulation when the amount of output is small to moderate. The output of Geant4 is forwarded to MessageLogger as in CustomUIsession, but a thread-specific prefix is added before each line of output. This makes it easier to grab the output of a specific thread.

Definition at line 13 of file CustomUIsessionThreadPrefix.h.

Constructor & Destructor Documentation

◆ CustomUIsessionThreadPrefix()

CustomUIsessionThreadPrefix::CustomUIsessionThreadPrefix ( const std::string &  threadPrefix,
int  threadId 
)
explicit

Definition at line 3 of file CustomUIsessionThreadPrefix.cc.

4  : CustomUIsession(), m_threadPrefix(threadPrefix + std::to_string(threadId) + ">> ") {}

◆ ~CustomUIsessionThreadPrefix()

CustomUIsessionThreadPrefix::~CustomUIsessionThreadPrefix ( )
override

Definition at line 6 of file CustomUIsessionThreadPrefix.cc.

6 {}

Member Function Documentation

◆ ReceiveG4cerr()

G4int CustomUIsessionThreadPrefix::ReceiveG4cerr ( const G4String &  cerrString)
override

Definition at line 30 of file CustomUIsessionThreadPrefix.cc.

30  {
31  edm::LogWarning("G4cerr") << addThreadPrefix(m_threadPrefix, trim(cerrString));
32  return 0;
33 }

References m_threadPrefix, and CustomUIsession::trim().

◆ ReceiveG4cout()

G4int CustomUIsessionThreadPrefix::ReceiveG4cout ( const G4String &  coutString)
override

Definition at line 24 of file CustomUIsessionThreadPrefix.cc.

24  {
25  //edm::LogInfo("G4cout") << addThreadPrefix(m_threadPrefix, trim(coutString));
26  edm::LogVerbatim("G4cout") << addThreadPrefix(m_threadPrefix, trim(coutString));
27  return 0;
28 }

References m_threadPrefix, and CustomUIsession::trim().

Member Data Documentation

◆ m_threadPrefix

const std::string CustomUIsessionThreadPrefix::m_threadPrefix
private

Definition at line 22 of file CustomUIsessionThreadPrefix.h.

Referenced by ReceiveG4cerr(), and ReceiveG4cout().

CustomUIsession::trim
std::string trim(const std::string &str)
Definition: CustomUIsession.cc:29
edm::LogWarning
Log< level::Warning, false > LogWarning
Definition: MessageLogger.h:122
CustomUIsessionThreadPrefix::m_threadPrefix
const std::string m_threadPrefix
Definition: CustomUIsessionThreadPrefix.h:22
CustomUIsession::CustomUIsession
CustomUIsession()
Definition: CustomUIsession.cc:3
edm::LogVerbatim
Log< level::Info, true > LogVerbatim
Definition: MessageLogger.h:128