33 #define INCLXX_IN_GEANT4_MODE 1
40 #ifdef INCLXX_IN_GEANT4_MODE
45 #if defined(INCL_DEBUG_LOG) && !defined(INCLXX_IN_GEANT4_MODE)
48 return std::string(
"Error");
50 return std::string (
"Fatal");
52 return std::string(
"Warning");
54 return std::string(
"Debug");
56 return std::string(
"");
58 return std::string(
"DataBlock");
60 return std::string(
"Unknown");
63 void LoggerSlave::logMessage(
const MessageType type,
const std::string &fileName,
const G4int lineNumber, std::string
const &
s)
const {
69 std::stringstream headerss;
70 headerss << typeToString(type) <<
" [";
71 std::string cont(
"\n");
72 cont += headerss.str();
74 fileName.substr(fileName.find_last_of(
"/")+1) <<
75 ":" << lineNumber <<
"] ";
76 std::string header = headerss.str();
77 cont.append(header.size() - cont.size() - 1,
'.');
80 std::string message(s);
82 (*logStream) << header << message;
87 void LoggerSlave::logDataBlock(
const std::string &
block,
const std::string &fileName,
const G4int lineNumber)
const {
89 fileName.substr(fileName.find_last_of(
"/")+1) <<
90 ":" << lineNumber <<
"] " << std::endl
93 <<
"ENDDATA" << std::endl;
102 void logMessage(
const MessageType type, std::string
const &fileName,
const G4int lineNumber, std::string
const &s) {
103 theLoggerSlave->logMessage(type, fileName, lineNumber, s);
106 void flush() { theLoggerSlave->flush(); }
108 void dataBlock(
const std::string &block,
const std::string &fileName,
const G4int lineNumber) {
109 theLoggerSlave->logDataBlock(block, fileName, lineNumber);
112 void setLoggerSlave(LoggerSlave *
const logger) { theLoggerSlave = logger; }
114 void setVerbosityLevel(
G4int lvl) { theLoggerSlave->setVerbosityLevel(lvl); }
118 void deleteLoggerSlave() {
119 delete theLoggerSlave;
125 #else // defined(INCL_DEBUG_LOG) && !defined(INCLXX_IN_GEANT4_MODE)
134 const char *
const envVar = getenv(
"G4INCL_DEBUG_VERBOSITY");
136 std::stringstream verbss(envVar);
137 verbss >> verbosityLevel;
144 return verbosityLevel;
149 #endif // defined(INCL_DEBUG_LOG) && !defined(INCLXX_IN_GEANT4_MODE)
void initVerbosityLevelFromEnvvar()
void replaceAll(std::string &str, const std::string &from, const std::string &to, const size_t maxPosition=std::string::npos)
G4int getVerbosityLevel()