34#define INCLXX_IN_GEANT4_MODE 1
38#ifndef G4INCLLogger_hh
39#define G4INCLLogger_hh 1
47#ifdef INCLXX_IN_GEANT4_MODE
67#if defined(INCL_DEBUG_LOG) && !defined(INCLXX_IN_GEANT4_MODE)
72 LoggerSlave(std::string
const &logFileName,
const G4int verbosity=4) :
74 verbosityLevel(verbosity)
76 if(logFileName==
"-") {
77 logStream = &(std::cout);
81 logStream =
new std::ofstream(logFileName.c_str());
84 std::cerr <<
"Fatal error: couldn't open log file " << logFileName << std::endl;
85 std::exit(EXIT_FAILURE);
90 std::boolalpha(*logStream);
100 void setVerbosityLevel(
G4int lvl) { verbosityLevel = lvl; }
108 void logMessage(
const MessageType type,
const std::string &fileName,
const G4int lineNumber, std::string
const &s,
const G4bool prefixHash=
true)
const;
111 void flush() { logStream->flush(); }
114 void logDataBlock(
const std::string &
block,
const std::string &fileName,
const G4int lineNumber)
const;
116 typedef std::basic_ostream<char, std::char_traits<char> > CoutType;
117 typedef CoutType& (*StandardEndLine)(CoutType&);
119 LoggerSlave
const &
operator<<(StandardEndLine
const &manip)
const {
126 LoggerSlave
const &
operator<<(
const T &t)
const {
132 std::ostream *logStream;
133 G4int verbosityLevel;
139 void logMessage(
const MessageType type, std::string
const &fileName,
const G4int lineNumber, std::string
const &s,
const G4bool prefixHash=
true);
145 void dataBlock(
const std::string &
block,
const std::string &fileName,
const G4int lineNumber);
148 void setLoggerSlave(LoggerSlave *
const logger);
151 void setVerbosityLevel(
G4int lvl);
157 void deleteLoggerSlave();
160 void initialize(Config
const *
const theConfig);
165#define INCL_FATAL(x) \
167 std::stringstream ss_;\
169 ss_ << "Random seeds at the beginning of this event: " << G4INCL::Random::getSavedSeeds() << std::endl;\
170 G4INCL::Logger::logMessage(G4INCL::FatalMsg, __FILE__,__LINE__, ss_.str());\
171 G4INCL::Logger::flush();\
172 std::exit(EXIT_FAILURE);\
174#define INCL_ERROR(x) \
175 if(G4INCL::ErrorMsg <= G4INCL::Logger::getVerbosityLevel()) {\
176 std::stringstream ss_;\
178 ss_ << "Random seeds at the beginning of this event: " << G4INCL::Random::getSavedSeeds() << std::endl;\
179 G4INCL::Logger::logMessage(G4INCL::ErrorMsg, __FILE__,__LINE__, ss_.str());\
181#define INCL_WARN(x) \
182 if(G4INCL::WarningMsg <= G4INCL::Logger::getVerbosityLevel()) {\
183 std::stringstream ss_;\
185 G4INCL::Logger::logMessage(G4INCL::WarningMsg, __FILE__,__LINE__, ss_.str());\
187#define INCL_INFO(x) \
188 if(G4INCL::InfoMsg <= G4INCL::Logger::getVerbosityLevel()) {\
189 std::stringstream ss_;\
191 G4INCL::Logger::logMessage(G4INCL::InfoMsg, __FILE__,__LINE__, ss_.str());\
193#define INCL_INFO_NOCOMMENT(x) \
194 if(G4INCL::InfoMsg <= G4INCL::Logger::getVerbosityLevel()) {\
195 std::stringstream ss_;\
197 G4INCL::Logger::logMessage(G4INCL::InfoMsg, __FILE__,__LINE__, ss_.str(), false);\
199#define INCL_DEBUG(x) \
200 if(G4INCL::DebugMsg <= G4INCL::Logger::getVerbosityLevel()) {\
201 std::stringstream ss_;\
203 G4INCL::Logger::logMessage(G4INCL::DebugMsg, __FILE__,__LINE__, ss_.str());\
205#define INCL_DATABLOCK(x) \
206 if(G4INCL::DataBlockMsg <= G4INCL::Logger::getVerbosityLevel()) {\
207 G4INCL::Logger::dataBlock(x,__FILE__,__LINE__);\
216#define INCL_FATAL(x) \
218 std::stringstream ss_;\
220 std::stringstream location_;\
221 std::string fileName_(__FILE__);\
222 location_ << fileName_.substr(fileName_.find_last_of("/")+1) << ":" << __LINE__;\
223 G4Exception(location_.str().c_str(), "INCLXX0000", EventMustBeAborted, ss_.str().c_str());\
225#define INCL_ERROR(x) \
226 if(G4INCL::ErrorMsg <= G4INCL::Logger::getVerbosityLevel()) {\
227 std::string fileName_(__FILE__);\
228 std::stringstream ss_;\
229 ss_ << "INCL++ error [" << fileName_.substr(fileName_.find_last_of("/")+1) << ":" << __LINE__ << "] " << x;\
230 G4cout << ss_.str() << '\n';\
232#define INCL_WARN(x) \
233 if(G4INCL::WarningMsg <= G4INCL::Logger::getVerbosityLevel()) {\
234 std::string fileName_(__FILE__);\
235 std::stringstream ss_;\
236 ss_ << "INCL++ warning [" << fileName_.substr(fileName_.find_last_of("/")+1) << ":" << __LINE__ << "] " << x;\
237 G4cout << ss_.str() << '\n';\
240#define INCL_DEBUG(x) \
241 if(G4INCL::DebugMsg <= G4INCL::Logger::getVerbosityLevel()) {\
242 std::string fileName_(__FILE__);\
243 std::stringstream ss_;\
244 ss_ << "INCL++ debug [" << fileName_.substr(fileName_.find_last_of("/")+1) << ":" << __LINE__ << "] " << x;\
245 G4cout << ss_.str() << '\n';\
247#define INCL_DATABLOCK(x);
std::ostream & operator<<(std::ostream &out, const G4CellScoreComposer &ps)
void initialize(Config const *const theConfig)
Initialize the clustering model based on the Config object.
G4int getVerbosityLevel()
void initVerbosityLevelFromEnvvar()