tp::utils::StandardReportHandler class

A tp::DebugReportHandler implementation with default message formatting, writing to a standard output stream.

Base classes

class tp::DebugReportHandler
A base class for debug report handlers, containing callbacks through which debug messages and runtime errors are reported.

Public static functions

static auto formatDebugMessage(const tp::DebugMessage& message) -> std::string noexcept
Formats the debug message as a string in the default way, without the severity prefix.
static auto formatRuntimeError(const tp::DebugMessageContext& context, const tp::RuntimeError& error) -> std::string noexcept
Formats the error as a string in the default way, without the prefix.
static void triggerDebugTrap() noexcept
Triggers a debug trap (breakpoint) in a multiplatform way if a debugger is attached.

Constructors, destructors, conversion operators

StandardReportHandler(std::ostream& outStream = std::cerr, tp::DebugMessageSeverityMask severityMask = tp::DebugMessageSeverity::Warning|tp::DebugMessageSeverity::Error, tp::DebugMessageTypeMask typeMask = tp::DebugMessageType::General|tp::DebugMessageType::Validation|tp::DebugMessageType::Performance, DebugMessageSeverityMask trapSeverityMask = tp::DebugMessageSeverity::Error)

Public functions

void callbackMessage(const tp::DebugMessage& message) override noexcept
Will be called on a debug message.
void callbackRuntimeError(const tp::DebugMessageContext& context, const tp::RuntimeError& error) override noexcept
Will be called when a Tephra error is about to be thrown.
void clearSeenSeverities()
Clears the mask of seen severities.
auto getSeenSeverities() const -> tp::DebugMessageSeverityMask
Returns a mask of severities of all messages that have been logged so far.
auto getSeverityMask() const -> tp::DebugMessageSeverityMask override noexcept
Returns the message severity mask. Only messages with these levels will be passed to tp::DebugReportHandler::callbackMessage.
auto getTypeMask() const -> tp::DebugMessageTypeMask override noexcept
Returns the message severity mask. Only messages of these types will be passed to tp::DebugReportHandler::callbackMessage.

Function documentation

static std::string tp::utils::StandardReportHandler::formatDebugMessage(const tp::DebugMessage& message) noexcept

Formats the debug message as a string in the default way, without the severity prefix.

Parameters
message The details of the message.

static std::string tp::utils::StandardReportHandler::formatRuntimeError(const tp::DebugMessageContext& context, const tp::RuntimeError& error) noexcept

Formats the error as a string in the default way, without the prefix.

Parameters
context The Tephra context of where the error was triggered.
error The runtime error thrown.

tp::utils::StandardReportHandler::StandardReportHandler(std::ostream& outStream = std::cerr, tp::DebugMessageSeverityMask severityMask = tp::DebugMessageSeverity::Warning|tp::DebugMessageSeverity::Error, tp::DebugMessageTypeMask typeMask = tp::DebugMessageType::General|tp::DebugMessageType::Validation|tp::DebugMessageType::Performance, DebugMessageSeverityMask trapSeverityMask = tp::DebugMessageSeverity::Error)

Parameters
outStream The output stream that messages and errors will be reported to.
severityMask The mask of severity levels to be reported.
typeMask The mask of message types to be reported.
trapSeverityMask The mask of severity levels that will attempt to trigger a debug trap (breakpoint) if a debugger is attached. The message must be reported to do so, therefore severityMask and typeMask also need to be satisfied. Does not work with all debuggers.

void tp::utils::StandardReportHandler::callbackMessage(const tp::DebugMessage& message) override noexcept

Will be called on a debug message.

Parameters
message The details of the message.

void tp::utils::StandardReportHandler::callbackRuntimeError(const tp::DebugMessageContext& context, const tp::RuntimeError& error) override noexcept

Will be called when a Tephra error is about to be thrown.

Parameters
context The Tephra context of where the error was triggered.
error The runtime error thrown.

tp::DebugMessageSeverityMask tp::utils::StandardReportHandler::getSeenSeverities() const

Returns a mask of severities of all messages that have been logged so far.

This can be useful to terminate an application after a validation error has been observed.