35#define INCLXX_IN_GEANT4_MODE 1
39#ifndef G4INCLLogger_hh
40#define G4INCLLogger_hh 1
66 LoggerSlave(std::string
const &logFileName) : logStream(0), verbosityLevel(4) {
67 if(logFileName==
"-") {
68#ifdef INCLXX_IN_GEANT4_MODE
71 logStream = &(std::cout);
76 logStream =
new std::ofstream(logFileName.c_str());
79 std::cerr <<
"Fatal error: couldn't open log file " << logFileName << std::endl;
80 std::exit(EXIT_FAILURE);
85 std::boolalpha(*logStream);
87#ifndef INCLXX_IN_GEANT4_MODE
88 logMessage(
InfoMsg, __FILE__,__LINE__,
"# Logging enabled!\n");
104 G4int getVerbosityLevel() {
return verbosityLevel; }
107 void logMessage(
const MessageType type,
const std::string &fileName,
const G4int lineNumber, std::string
const &s)
const;
110 void flush() { logStream->flush(); }
113 void logDataBlock(
const std::string &
block,
const std::string &fileName,
const G4int lineNumber)
const;
115 typedef std::basic_ostream<char, std::char_traits<char> > CoutType;
116 typedef CoutType& (*StandardEndLine)(CoutType&);
131 std::ostream *logStream;
132 G4int verbosityLevel;
139 static void logMessage(
const MessageType type, std::string
const &fileName,
const G4int lineNumber, std::string
const &s) {
140 theLoggerSlave->logMessage(type, fileName, lineNumber, s);
144 static void flush() { theLoggerSlave->flush(); }
147 static void dataBlock(
const std::string &
block,
const std::string &fileName,
const G4int lineNumber) {
148 theLoggerSlave->logDataBlock(
block, fileName, lineNumber);
152 static void setLoggerSlave(LoggerSlave *
const logger) { theLoggerSlave = logger; }
158 static G4int getVerbosityLevel() {
return theLoggerSlave->getVerbosityLevel(); }
162 delete theLoggerSlave;
167 static LoggerSlave *theLoggerSlave;
172 if(G4INCL::FatalMsg <= G4INCL::Logger::getVerbosityLevel()) {\
173 std::stringstream ss;\
175 G4INCL::Logger::logMessage(G4INCL::FatalMsg, __FILE__,__LINE__, ss.str());\
176 G4INCL::Logger::flush();\
179 if(G4INCL::ErrorMsg <= G4INCL::Logger::getVerbosityLevel()) {\
180 std::stringstream ss;\
182 G4INCL::Logger::logMessage(G4INCL::ErrorMsg, __FILE__,__LINE__, ss.str());\
185 if(G4INCL::WarningMsg <= G4INCL::Logger::getVerbosityLevel()) {\
186 std::stringstream ss;\
188 G4INCL::Logger::logMessage(G4INCL::WarningMsg, __FILE__,__LINE__, ss.str());\
191 if(G4INCL::InfoMsg <= G4INCL::Logger::getVerbosityLevel()) {\
192 std::stringstream ss;\
194 G4INCL::Logger::logMessage(G4INCL::InfoMsg, __FILE__,__LINE__, ss.str());\
197 if(G4INCL::DebugMsg <= G4INCL::Logger::getVerbosityLevel()) {\
198 std::stringstream ss;\
200 G4INCL::Logger::logMessage(G4INCL::DebugMsg, __FILE__,__LINE__, ss.str());\
202#define DATABLOCK(x) \
203 if(G4INCL::DataBlockMsg <= G4INCL::Logger::getVerbosityLevel()) {\
204 G4INCL::Logger::dataBlock(x,__FILE__,__LINE__);\
224 delete theLoggerSlave;
std::ostream & operator<<(std::ostream &out, const G4CellScoreComposer &ps)
G4DLLIMPORT std::ostream G4cout
LoggerSlave(std::string const &)
void setVerbosityLevel(G4int)
static void setLoggerSlave(LoggerSlave *const slave)
static void deleteLoggerSlave()
static void setVerbosityLevel(G4int)