GGS(GenericGEANT4Simulation)Software  2.99.0
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Macros
GGSSmartLog.h
Go to the documentation of this file.
1 /*
2  * GGSSmartLog.h
3  *
4  * Created on: 01 Jan 2014
5  * Author: Nicola Mori
6  */
7 
10 #ifndef GGSSMARTLOG_H_
11 #define GGSSMARTLOG_H_
12 
13 #include <iomanip>
14 #include <iostream>
15 
16 namespace GGSSmartLog {
24 enum { SILENT, ERROR, WARNING, INFO, DEBUG, DEEPDEB };
25 extern const char
26  *levelNames[6];
27 extern int verboseLevel;
28 extern int maxRoutineNameLength;
29 
39 extern const std::string &Format(const std::string &str, unsigned int maxLength);
40 
46 extern void MuteOutput();
47 
52 extern void UnmuteOutput();
53 
54 #ifdef GGS_USE_G4
55 
60 extern void MuteG4Output();
61 
66 extern void UnmuteG4Output();
67 
68 #endif
69 
70 } // namespace GGSSmartLog
71 
95 #ifdef GGSMULTITHREADED
96 #include "G4ios.hh"
97 
98 #define GGSCOUT_BACKEND G4cout
99 #else
100 #define GGSCOUT_BACKEND std::cout
101 #endif
102 #define GGSCOUT(level) \
103  if (GGSSmartLog::verboseLevel >= GGSSmartLog::level) \
104  GGSCOUT_BACKEND \
105  << std::setw(GGSSmartLog::maxRoutineNameLength + 3) << std::left \
106  << std::string("[").append(GGSSmartLog::Format(routineName, GGSSmartLog::maxRoutineNameLength)).append("] ") \
107  << std::setw(10) << GGSSmartLog::levelNames[GGSSmartLog::level]
108 
126 #define GGSCCOUT(level) \
127  if (GGSSmartLog::verboseLevel >= GGSSmartLog::level) \
128  GGSCOUT_BACKEND << std::setw(GGSSmartLog::maxRoutineNameLength + 13) << " "
129 
131 #define GGSENDL std::endl
132 
133 #endif /* GGSSMARTLOG_H_ */