20 #ifndef INITIALIZATION_ERROR_LOGGER_HPP
21 #define INITIALIZATION_ERROR_LOGGER_HPP
24 #include "common/format/Format.hpp"
197 template<
typename ... Args >
200 ( this->addContextInfoImpl(
ErrorContext( args ) ), ... );
309 { m_writeYaml = value; }
315 {
return m_writeYaml; }
323 { m_filename = filename; }
329 {
return m_filename; }
348 {
return m_getCurrentExceptionMsg;}
401 bool m_writeYaml =
false;
405 std::ostream & m_stream = std::cout;
407 std::mutex m_errorHandlerAsciiMutex;
409 std::mutex m_errorHandlerYamlMutex;
423 void streamMultilineYamlAttribute(
std::string_view msg, std::ofstream & yamlFile,
#define GEOS_HOST
Marks a host-only function.
Builder class for constructing DiagnosticMsg objects.
DiagnosticMsgBuilder & addRank(integer rank)
Add a rank on which the error has been raised.
DiagnosticMsgBuilder & addContextInfo(Args &&... args)
Adds one or more context elements to the error.
DiagnosticMsgBuilder & addDetectionLocation(string_view detectionLocation)
Add where the detection occured.
DiagnosticMsgBuilder & setCause(std::string_view cause)
Set the cause of the error.
DiagnosticMsgBuilder & setCodeLocation(std::string_view msgFile, integer msgLine)
Set the source code location values (file and line where the error is detected)
DiagnosticMsgBuilder & addCallStackInfo(std::string_view stacktrace)
Add the stack trace information about the error.
DiagnosticMsgBuilder & addToMsg(std::exception const &e, bool toEnd=false)
Append exception text to the message.
DiagnosticMsgBuilder & addSignal(integer sig, bool toEnd=false)
Add the signal to the DiagnosticMsg.
static DiagnosticMsgBuilder init(DiagnosticMsg &msg, MsgType msgType, std::string_view msgContent, integer rank)
Initialize a new DiagnosticMsg.
DiagnosticMsg & getDiagnosticMsg()
DiagnosticMsgBuilder & addToMsg(std::string_view msg, bool toEnd=false)
Append text to the message.
DiagnosticMsgBuilder & setType(MsgType msgType)
Set the type of the error, (amoung one of the MsgType)
static DiagnosticMsgBuilder modify(DiagnosticMsg &errorMsg)
Modify an existing DiagnosticMsg.
Logger for formatting and outputting diagnostics.
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".
std::ostream const & getErrorStream() const
DiagnosticMsgBuilder modifyCurrentExceptionMessage()
Modify/Continue building the current exception message.
void createFile()
Create the YAML file or overwrite the contents if a YAML file of the same name already exists And wri...
static void formatMsgForLog(DiagnosticMsg const &errMsg, std::ostream &os)
Format all information in ErrorMsg and write it to the specified output stream.
DiagnosticMsgBuilder initCurrentExceptionMessage(MsgType msgType, std::string_view msgContent, integer rank)
Start building a new exception message.
void writeToLogStream(DiagnosticMsg &errMsg)
Write the ErrorMsg into the log stream output stream.
std::string_view getOutputFilename()
void enableFileOutput(bool value)
Enable the YAML file output, which is false by default.
static GEOS_HOST ErrorLogger & global()
bool isOutputFileEnabled() const
DiagnosticMsg const & getCurrentExceptionMsg() const
void flushErrorMsg(DiagnosticMsg &errMsg)
Write all the information retrieved about the diagnostic message into the instance outputs (stream sp...
void flushCurrentExceptionMessage()
Write all the information retrieved about the current exception message into the instance outputs (st...
Base template for ordered and unordered maps.
std::string string
String type.
int integer
Signed integer type.
std::string_view string_view
String type.
Struct to construct the diagnostic message object.
std::set< int > m_ranksInfo
the rank(s) on which the diagnostic occured
std::vector< ErrorContext > m_contextsInfo
Additional information about the diagnostic in the input file.
std::string m_file
the source location file
integer m_line
the source location line (default is 0)
MsgType m_type
Type of diagnostic (Warning, Error or Exception)
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)
bool m_isValidStackTrace
Indicates whether the stored call stack trace is valid and usable.
std::string m_msg
the message that can be completed
ErrorContext(string formattedContext, map< Attribute, std::string > attributes)
Construct to initialize ErrorContext.
integer m_priority
Priority level assigned to an error context.
static std::string attributeToString(Attribute attribute)
Convert a value from the Attribute enumeration to a string.
string m_formattedContext
String containing the target object name followed by the the file and line declaring it.
ErrorContext & setPriority(integer priority)
Set the priority value of the current error context information. This way the different context infor...
ErrorContext(string formattedContext, map< Attribute, std::string > attributes, integer priority)
Construct to initialize ErrorContext given a string containing the context and his priority.
map< Attribute, std::string > m_attributes
The map contains contextual information about the error It could be something like "file" = "/path/to...
Geos Exception used in GEOS_THROW.