8 #ifndef Pythia8_Logger_H 9 #define Pythia8_Logger_H 11 #include "Pythia8/PythiaStdlib.h" 23 class Logger :
private streambuf,
public ostream {
29 bool operator() (
const string& a,
const string& b)
const {
30 char a1 = a[0], b1 = b[0];
31 int severityA, severityB;
32 if (a1 ==
'A') severityA = 0;
33 else if (a1 ==
'E') severityA = 1;
34 else if (a1 ==
'W') severityA = 2;
35 else if (a1 ==
'I') severityA = 3;
36 else if (a1 ==
'R') severityA = 4;
38 if (b1 ==
'A') severityB = 0;
39 else if (b1 ==
'E') severityB = 1;
40 else if (b1 ==
'W') severityB = 2;
41 else if (b1 ==
'I') severityB = 3;
42 else if (b1 ==
'R') severityB = 4;
44 if (severityA != severityB)
return severityA < severityB;
52 Logger() : ostream(this), infoStreamSave(cout), errStreamSave(cerr),
53 verbosity(2), printInitSave(true), printNextSave(true), printErrors(true),
54 isQuietSave(false), useErrorStream(false) { }
63 void reportMsg(
string loc,
string message,
string extraInfo =
"",
64 bool showAlways =
false);
67 void infoMsg(
string loc,
string message,
string extraInfo =
"",
68 bool showAlways =
false);
71 void warningMsg(
string loc,
string message,
string extraInfo =
"",
72 bool showAlways =
false);
75 void errorMsg(
string loc,
string message,
string extraInfo =
"",
76 bool showAlways =
false);
79 void abortMsg(
string loc,
string message,
string extraInfo =
"",
80 bool showAlways =
false);
83 bool isQuiet()
const {
return isQuietSave; }
86 bool mayPrintInit()
const {
return printInitSave && !isQuietSave; }
89 bool mayPrintNext()
const {
return printNextSave && !isQuietSave; }
96 int getVerbosity()
const {
return verbosity; }
107 for (pair<string, int> messageEntry : messages)
108 nTot += messageEntry.second;
116 ostream& infoStream() {
return infoStreamSave; }
117 ostream& errorStream() {
118 return useErrorStream ? errStreamSave : infoStreamSave; }
121 map<string, int, LogComparer>::iterator
begin() {
122 return messages.begin(); }
123 map<string, int, LogComparer>::iterator end() {
124 return messages.end(); }
125 map<string, int, LogComparer>::const_iterator
begin()
const {
126 return messages.begin(); }
127 map<string, int, LogComparer>::const_iterator end()
const {
128 return messages.end(); }
140 map<string, int, LogComparer> messages;
144 int overflow(
int c)
override {
145 infoStreamSave.put(c);
150 ostream& infoStreamSave;
152 ostream& errStreamSave;
156 bool printInitSave, printNextSave, printErrors, isQuietSave, useErrorStream;
162 void msg(
int verbosityLevel,
string message,
string extraInfo =
"",
163 bool showAlways =
false);
171 #define INFO_MSG(...) infoMsg(__METHOD_NAME__, __VA_ARGS__) 172 #define WARNING_MSG(...) warningMsg(__METHOD_NAME__, __VA_ARGS__) 173 #define ERROR_MSG(...) errorMsg(__METHOD_NAME__, __VA_ARGS__) 174 #define ABORT_MSG(...) abortMsg(__METHOD_NAME__, __VA_ARGS__) 175 #define REPORT_MSG(...) reportMsg(__METHOD_NAME__, __VA_ARGS__) bool mayPrintErrors() const
Indicates whether error messages will be printed.
Definition: Logger.h:92
int errorTotalNumber() const
Total number of errors/aborts/warnings logged.
Definition: Logger.h:105
void infoMsg(string loc, string message, string extraInfo="", bool showAlways=false)
Info messages are diagnostic messages that don't indicate an issue.
Definition: Logger.cc:29
bool mayPrintNext() const
Indicates whether information will be printed during event generation.
Definition: Logger.h:89
void reportMsg(string loc, string message, string extraInfo="", bool showAlways=false)
Report messages contain information not relevant in normal runs.
Definition: Logger.cc:26
void warningMsg(string loc, string message, string extraInfo="", bool showAlways=false)
Warnings indicate that there might be an issue, but the run will continue.
Definition: Logger.cc:32
static constexpr int ABORT
Abort verbosity level: print only abort messages.
Definition: Logger.h:131
void errorReset()
Reset to empty map of error messages.
Definition: Logger.h:102
void errorMsg(string loc, string message, string extraInfo="", bool showAlways=false)
Errors indicate an issue that might cause the current event to fail.
Definition: Logger.cc:35
map< string, int, LogComparer >::iterator begin()
Iterators over error messages.
Definition: Logger.h:121
bool mayPrintInit() const
Indicates whether information will be printed during initialization.
Definition: Logger.h:86
void errorCombine(const Logger &other, string prefix="")
Add all errors from the other Logger object to the counts of this object.
Definition: Logger.cc:68
static constexpr int REPORT
Report verbosity level: print everything, including report messages.
Definition: Logger.h:135
Logger()
Construct with default values.
Definition: Logger.h:52
static constexpr int NORMAL
Normal verbosity level: print errors, warnings and info messages.
Definition: Logger.h:133
void abortMsg(string loc, string message, string extraInfo="", bool showAlways=false)
Aborts indicate critical issues that prevent further event generation.
Definition: Logger.cc:38
void setVerbosity(int verbosityIn)
0: no messages | 1: aborts only | 2: default | 3: debug
Definition: Logger.h:95
Header for classes to set beam momentum and interaction vertex spread.
Definition: Analysis.h:20
bool isQuiet() const
If quiet, the logger will not print any messages.
Definition: Logger.h:83
void errorStatistics() const
Print error statistics.
Definition: Logger.h:113
Definition: Settings.h:195