20 #ifndef INITIALIZATION_ERROR_LOGGER_HPP
21 #define INITIALIZATION_ERROR_LOGGER_HPP
202 template<
typename ... Args >
209 {
return m_isValidStackTrace; }
218 bool m_isValidStackTrace =
false;
234 {
return m_writeYaml; }
241 { m_writeYaml = value; }
249 { m_filename = filename; }
255 {
return m_filename; }
264 {
return m_currentErrorMsg; }
290 bool m_writeYaml =
false;
299 void streamMultilineYamlAttribute(
std::string_view msg, std::ofstream & yamlFile,
305 template<
typename ... Args >
308 ( this->addContextInfoImpl( ErrorContext( args ) ), ... );
#define GEOS_HOST
Marks a host-only function.
Class to format and write different error/warning information that occured during the initialization.
static std::string toString(MsgType type)
Convert a MsgType into a string.
void setOutputFilename(std::string_view filename)
Set the name of the YAML file if specified by user default is "errors.yaml".
void createFile()
Create the YAML file or overwrite the contents if a YAML file of the same name already exists And wri...
std::string_view getOutputFilename()
ErrorMsg & currentErrorMsg()
Gives acces to the error message that is currently being constructed, potencially at various applicat...
void enableFileOutput(bool value)
Enable the YAML file output, which is false by default.
static GEOS_HOST ErrorLogger & global()
bool isOutputFileEnabled() const
void flushErrorMsg(ErrorMsg &errorMsg)
Write all the information retrieved about the error/warning message into the YAML file and reset the ...
Base template for ordered and unordered maps.
std::string string
String type.
int integer
Signed integer type.
std::string_view string_view
String type.
static std::string attributeToString(Attribute attribute)
Convert a value from the Attribute enumeration to a string.
map< Attribute, std::string > m_attributes
ErrorContext & setPriority(integer priority)
Set the priority value of the current error context information.
integer m_priority
Priority level assigned to an error context.
Struct to construct the error/warning object.
std::vector< std::string > m_sourceCallStack
the stack trace
std::string m_cause
the cause of the error (erroneous condition, failed assertion...) if identified (optional)
ErrorMsg & setCause(std::string_view cause)
Set the cause of the error.
ErrorMsg & addContextInfo(Args &&... args)
Adds one or more context elements to the error.
bool isValidStackTrace() const
std::vector< ErrorContext > m_contextsInfo
Additional information about the error in the input file.
ErrorMsg & setCodeLocation(std::string_view msgFile, integer msgLine)
Set the source code location values (file and line where the error is detected)
std::set< int > m_ranksInfo
the rank(s) on which the error occured
ErrorMsg()
Construct a default Error Message.
integer m_line
the source location line corresponding to the error in the code (default is 0)
ErrorMsg(MsgType msgType, std::string_view msgContent, integer rank, std::string_view msgFile, integer msgLine)
Construct a new Error Message from parameters.
ErrorMsg & setType(MsgType msgType)
Set the type of the error.
ErrorMsg & addRank(int rank)
Add a rank on which the error has been raised.
ErrorMsg & addToMsg(std::exception const &e, bool toEnd=false)
Add text to the current error msg.
ErrorMsg & addToMsg(std::string_view msg, bool toEnd=false)
Add text to the current error msg.
ErrorMsg & addCallStackInfo(std::string_view ossStackTrace)
Add stack trace information about the error.
std::string m_file
the source location file corresponding to the error in the code
std::string m_msg
the error message that can be completed
MsgType m_type
the error type (Warning, Error or Exception)