NDEVR
API Documentation
LogMessage

A class that allows for specific log information to be conveyed to a InfoPipe object including information about severity and timestamp information. More...

Collaboration diagram for LogMessage:
[legend]

Public Types

enum  ApplicationMessagePriority : uint01 {
  e_success = 0 , e_debug = 1 , e_logged_debug = 2 , e_notification = 5 ,
  e_warning = 50 , e_error = 150 , e_critical_error = 250
}
 Defines severity levels for log messages, ranging from success to critical error. More...

Public Member Functions

 LogMessage ()
 Constructs a default LogMessage with no content.
 LogMessage (const StringView &message, const uint01 error_level=e_notification)
 Constructs a LogMessage from a string view with an optional error level.
 LogMessage (const Time &time, const StringView &message, const uint01 error_level, uint02 session)
 Constructs a LogMessage with a specific time, message, error level, and session number.
 LogMessage (const Time &time, const StringView &message, const uint01 error_level=e_notification)
 Constructs a LogMessage with a specific time, message, and error level.
 LogMessage (const TranslatedString &message, const uint01 error_level=e_notification)
 Constructs a LogMessage from a translated string with an optional error level.
Buffer< std::pair< String, String > > ansiiEscapeBlocks () const
 Parses the message into pairs of ANSI escape code sequences and their associated text.
void appendMessage (StringAllocatingView &message, bool include_new_lines, bool include_tabs, bool include_colors) const
 Appends the formatted message to an existing string with optional formatting controls.
bool hasFormatting () const
 Checks whether the message contains ANSI escape code formatting.
bool hasSubString (const StringView &s, bool ignore_case=false) const
 Checks whether the message contains a given substring.
bool isFromCurrentSession () const
 Checks whether this log message was generated during the current application session.
bool isSessionEnd () const
 Checks whether this message is a session end marker.
bool isSessionStart () const
 Checks whether this message is a session start marker.
uint01 logRecordLevel () const
 Returns the severity level of this log message.
StringAllocatingView message (bool include_new_lines, bool include_tabs, bool include_colors) const
 Returns the formatted message string with optional formatting controls.
AlocatingAlignedBuffer< TextBlock, 64 > messageBlocks (const Font &default_font) const
 Converts the message into styled TextBlock objects using the specified default font.
StringrawMessage ()
 Returns a mutable reference to the raw, unformatted message string.
const StringrawMessage () const
 Returns a const reference to the raw, unformatted message string.
Time recordTime () const
 Returns the timestamp when this log message was recorded.
uint02 sessionNumber () const
 Returns the session number that produced this log message.
void setErrorLevel (uint01 level)
 Sets the severity level of this log message.
void setRecordTime (const Time &time)
 Sets the timestamp of this log message.
void setSessionNumber (uint02 session)
 Sets the session number that produced this log message.

Static Public Member Functions

static uint02 CurrentLogSession ()
 Returns the identifier for the current active log session.
static constexpr StringView LogSessionEnd ()
 Returns the sentinel string that marks the end of a log session.
static constexpr StringView LogSessionStart ()
 Returns the sentinel string that marks the start of a log session.

Protected Attributes

uint01 m_error_level
 The severity level of this log message.
String m_message
 The raw log message content.
uint02 m_session_number
 The session number that produced this message.
Time m_time
 The timestamp when the message was recorded.

Detailed Description

A class that allows for specific log information to be conveyed to a InfoPipe object including information about severity and timestamp information.


Definition at line 47 of file LogMessage.h.

Member Enumeration Documentation

◆ ApplicationMessagePriority

Defines severity levels for log messages, ranging from success to critical error.

Enumerator
e_success 

Operation completed successfully.

e_debug 

Debug-level message, not persisted to the log.

e_logged_debug 

Debug-level message that is persisted to the log.

e_notification 

Informational notification for general status updates.

e_warning 

Warning indicating a potential issue.

e_error 

Error indicating a failure in an operation.

e_critical_error 

Critical error indicating a severe or unrecoverable failure.

Definition at line 53 of file LogMessage.h.

Constructor & Destructor Documentation

◆ LogMessage() [1/4]

LogMessage::LogMessage ( const Time & time,
const StringView & message,
const uint01 error_level,
uint02 session )

Constructs a LogMessage with a specific time, message, error level, and session number.

Parameters
[in]timeThe timestamp of the log entry.
[in]messageThe log message content.
[in]error_levelThe severity level of the message.
[in]sessionThe session number that produced this message.

References message().

◆ LogMessage() [2/4]

LogMessage::LogMessage ( const Time & time,
const StringView & message,
const uint01 error_level = e_notification )

Constructs a LogMessage with a specific time, message, and error level.

Parameters
[in]timeThe timestamp of the log entry.
[in]messageThe log message content.
[in]error_levelThe severity level of the message.

References e_notification, and message().

◆ LogMessage() [3/4]

LogMessage::LogMessage ( const StringView & message,
const uint01 error_level = e_notification )
explicit

Constructs a LogMessage from a string view with an optional error level.

Parameters
[in]messageThe log message content.
[in]error_levelThe severity level of the message.

References e_notification, and message().

◆ LogMessage() [4/4]

LogMessage::LogMessage ( const TranslatedString & message,
const uint01 error_level = e_notification )
explicit

Constructs a LogMessage from a translated string with an optional error level.

Parameters
[in]messageThe translated log message content.
[in]error_levelThe severity level of the message.

References e_notification, and message().

Member Function Documentation

◆ ansiiEscapeBlocks()

Buffer< std::pair< String, String > > LogMessage::ansiiEscapeBlocks ( ) const

Parses the message into pairs of ANSI escape code sequences and their associated text.

Returns
A Buffer of pairs where each pair contains an ANSI escape code and its text block.

◆ appendMessage()

void LogMessage::appendMessage ( StringAllocatingView & message,
bool include_new_lines,
bool include_tabs,
bool include_colors ) const

Appends the formatted message to an existing string with optional formatting controls.

Parameters
[in]messageThe string to append the formatted message to.
[in]include_new_linesWhether to include newline characters in the output.
[in]include_tabsWhether to include tab characters in the output.
[in]include_colorsWhether to include ANSI color escape codes in the output.

References message().

◆ CurrentLogSession()

uint02 LogMessage::CurrentLogSession ( )
static

Returns the identifier for the current active log session.

Returns
The current log session number.

◆ hasFormatting()

bool LogMessage::hasFormatting ( ) const

Checks whether the message contains ANSI escape code formatting.

Returns
True if the message contains formatting, false otherwise.

◆ hasSubString()

bool LogMessage::hasSubString ( const StringView & s,
bool ignore_case = false ) const

Checks whether the message contains a given substring.

Parameters
[in]sThe substring to search for.
[in]ignore_caseWhether to perform a case-insensitive search.
Returns
True if the substring is found, false otherwise.

◆ isFromCurrentSession()

bool LogMessage::isFromCurrentSession ( ) const

Checks whether this log message was generated during the current application session.

Returns
True if the message belongs to the current session, false otherwise.

◆ isSessionEnd()

bool LogMessage::isSessionEnd ( ) const
inline

Checks whether this message is a session end marker.

Returns
True if the message matches the session end sentinel.

Definition at line 156 of file LogMessage.h.

References LogSessionStart(), and m_message.

◆ isSessionStart()

bool LogMessage::isSessionStart ( ) const
inline

Checks whether this message is a session start marker.

Returns
True if the message matches the session start sentinel.

Definition at line 151 of file LogMessage.h.

References LogSessionStart(), and m_message.

◆ logRecordLevel()

uint01 LogMessage::logRecordLevel ( ) const
inline

Returns the severity level of this log message.

Returns
The error level as a uint01 value.

Definition at line 182 of file LogMessage.h.

References m_error_level.

◆ LogSessionEnd()

constexpr StringView LogMessage::LogSessionEnd ( )
inlinestaticconstexpr

Returns the sentinel string that marks the end of a log session.

Returns
A StringView containing the session end marker.

Definition at line 146 of file LogMessage.h.

◆ LogSessionStart()

constexpr StringView LogMessage::LogSessionStart ( )
inlinestaticconstexpr

Returns the sentinel string that marks the start of a log session.

Returns
A StringView containing the session start marker.

Definition at line 141 of file LogMessage.h.

Referenced by isSessionEnd(), and isSessionStart().

◆ message()

StringAllocatingView LogMessage::message ( bool include_new_lines,
bool include_tabs,
bool include_colors ) const

Returns the formatted message string with optional formatting controls.

Parameters
[in]include_new_linesWhether to include newline characters in the output.
[in]include_tabsWhether to include tab characters in the output.
[in]include_colorsWhether to include ANSI color escape codes in the output.
Returns
The formatted message as a StringAllocatingView.

Referenced by LogMessage(), LogMessage(), LogMessage(), LogMessage(), and appendMessage().

◆ messageBlocks()

AlocatingAlignedBuffer< TextBlock, 64 > LogMessage::messageBlocks ( const Font & default_font) const

Converts the message into styled TextBlock objects using the specified default font.

Parameters
[in]default_fontThe font to use for text blocks that have no explicit formatting.
Returns
An aligned buffer of TextBlock objects representing the styled message.

◆ rawMessage() [1/2]

String & LogMessage::rawMessage ( )
inline

Returns a mutable reference to the raw, unformatted message string.

Returns
Mutable reference to the raw message.

Definition at line 120 of file LogMessage.h.

References m_message.

◆ rawMessage() [2/2]

const String & LogMessage::rawMessage ( ) const
inline

Returns a const reference to the raw, unformatted message string.

Returns
Const reference to the raw message.

Definition at line 115 of file LogMessage.h.

References m_message.

◆ recordTime()

Time LogMessage::recordTime ( ) const
inline

Returns the timestamp when this log message was recorded.

Returns
The record time as a Time object.

Definition at line 168 of file LogMessage.h.

References m_time.

◆ sessionNumber()

uint02 LogMessage::sessionNumber ( ) const
inline

Returns the session number that produced this log message.

Returns
The session number as a uint02 value.

Definition at line 203 of file LogMessage.h.

References m_session_number.

◆ setErrorLevel()

void LogMessage::setErrorLevel ( uint01 level)
inline

Sets the severity level of this log message.

Parameters
[in]levelThe new error level.

Definition at line 189 of file LogMessage.h.

References m_error_level.

◆ setRecordTime()

void LogMessage::setRecordTime ( const Time & time)
inline

Sets the timestamp of this log message.

Parameters
[in]timeThe new record time.

Definition at line 175 of file LogMessage.h.

References m_time.

◆ setSessionNumber()

void LogMessage::setSessionNumber ( uint02 session)
inline

Sets the session number that produced this log message.

Parameters
[in]sessionThe session number to assign.

Definition at line 196 of file LogMessage.h.

References m_session_number.


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