GEOS
Public Member Functions | Static Public Member Functions | List of all members
geos::ErrorLogger Class Reference

Logger for formatting and outputting diagnostics. More...

#include <ErrorHandling.hpp>

Public Member Functions

void createFile ()
 Create the YAML file or overwrite the contents if a YAML file of the same name already exists And write its header when the command line option is enabled.
 
void enableFileOutput (bool value)
 Enable the YAML file output, which is false by default. More...
 
bool isOutputFileEnabled () const
 
void setOutputFilename (std::string_view filename)
 Set the name of the YAML file if specified by user default is "errors.yaml". More...
 
std::string_view getOutputFilename ()
 
std::ostream const & getErrorStream () const
 
DiagnosticMsg const & getCurrentExceptionMsg () const
 
DiagnosticMsgBuilder initCurrentExceptionMessage (MsgType msgType, std::string_view msgContent, integer rank)
 Start building a new exception message. More...
 
DiagnosticMsgBuilder modifyCurrentExceptionMessage ()
 Modify/Continue building the current exception message. More...
 
void flushCurrentExceptionMessage ()
 Write all the information retrieved about the current exception message into the instance outputs (stream specified + optional yaml file)
 
void flushErrorMsg (DiagnosticMsg &errMsg)
 Write all the information retrieved about the diagnostic message into the instance outputs (stream specified, std::cout by default + optional yaml file) More...
 
void writeToLogStream (DiagnosticMsg &errMsg)
 Write the ErrorMsg into the log stream output stream. More...
 

Static Public Member Functions

static GEOS_HOST ErrorLoggerglobal ()
 
static std::string toString (MsgType type)
 Convert a MsgType into a string. More...
 
static void formatMsgForLog (DiagnosticMsg const &errMsg, std::ostream &os)
 Format all information in ErrorMsg and write it to the specified output stream. More...
 

Detailed Description

Logger for formatting and outputting diagnostics.

Definition at line 284 of file ErrorHandling.hpp.

Member Function Documentation

◆ enableFileOutput()

void geos::ErrorLogger::enableFileOutput ( bool  value)
inline

Enable the YAML file output, which is false by default.

Parameters
valueA value of true enable the file writing

Definition at line 308 of file ErrorHandling.hpp.

◆ flushErrorMsg()

void geos::ErrorLogger::flushErrorMsg ( DiagnosticMsg errMsg)

Write all the information retrieved about the diagnostic message into the instance outputs (stream specified, std::cout by default + optional yaml file)

Parameters
errMsga reference to the ErrorMsg to output, and will be re-initialized
Note
Used for warnings and non-exception errors

◆ formatMsgForLog()

static void geos::ErrorLogger::formatMsgForLog ( DiagnosticMsg const &  errMsg,
std::ostream &  os 
)
static

Format all information in ErrorMsg and write it to the specified output stream.

Parameters
errMsgThe struct containing the error/warning object
osThe output stream

◆ getCurrentExceptionMsg()

DiagnosticMsg const& geos::ErrorLogger::getCurrentExceptionMsg ( ) const
inline
Returns
Return the const DiagnosticMsg

Definition at line 347 of file ErrorHandling.hpp.

◆ getErrorStream()

std::ostream const& geos::ErrorLogger::getErrorStream ( ) const
inline
Returns
Return the const general log stream

Definition at line 341 of file ErrorHandling.hpp.

◆ getOutputFilename()

std::string_view geos::ErrorLogger::getOutputFilename ( )
inline
Returns
The file name of the output error file

Definition at line 328 of file ErrorHandling.hpp.

◆ global()

static GEOS_HOST ErrorLogger& geos::ErrorLogger::global ( )
static
Returns
Global instance of the ErrorLogger class used for error/warning reporting.

This global instance is used across the codebase to log errors, warnings, and exceptions, and to write structured output of errors. It is used through the logging macros.

Note
- local instances are possible for more specialized logging.
  • currently not available on GPU, use GEOS_WARNING/ERROR/ASSERT macros for this usecase.

◆ initCurrentExceptionMessage()

DiagnosticMsgBuilder geos::ErrorLogger::initCurrentExceptionMessage ( MsgType  msgType,
std::string_view  msgContent,
integer  rank 
)

Start building a new exception message.

Parameters
msgTypeType of diagnostic (Warning, Error or Exception)
msgContentthe message that can be completed
rankthe rank(s) on which the diagnostic occured
Returns
Builder for the exception
Note
One exception can exist at a time

◆ isOutputFileEnabled()

bool geos::ErrorLogger::isOutputFileEnabled ( ) const
inline
Returns
true if the YAML file output is enabled

Definition at line 314 of file ErrorHandling.hpp.

◆ modifyCurrentExceptionMessage()

DiagnosticMsgBuilder geos::ErrorLogger::modifyCurrentExceptionMessage ( )
inline

Modify/Continue building the current exception message.

Returns
Builder for the exception

Definition at line 366 of file ErrorHandling.hpp.

◆ setOutputFilename()

void geos::ErrorLogger::setOutputFilename ( std::string_view  filename)
inline

Set the name of the YAML file if specified by user default is "errors.yaml".

Parameters
filenamethe name of the YAML file

Definition at line 322 of file ErrorHandling.hpp.

◆ toString()

static std::string geos::ErrorLogger::toString ( MsgType  type)
static

Convert a MsgType into a string.

Parameters
typethe message type label
Returns
the string representation of the message type

◆ writeToLogStream()

void geos::ErrorLogger::writeToLogStream ( DiagnosticMsg errMsg)

Write the ErrorMsg into the log stream output stream.

Parameters
errMsgThe struct containing the error/warning object

The documentation for this class was generated from the following file: