LogIt++
Header-only, macro-first C++ logging library
Loading...
Searching...
No Matches
logit::ILogFormatter Interface Referenceabstract

Interface for formatting log records. More...

#include <ILogFormatter.hpp>

Inheritance diagram for logit::ILogFormatter:
logit::SimpleLogFormatter

Public Member Functions

virtual ~ILogFormatter ()=default
 
virtual void set_timestamp_offset (int64_t offset_ms)=0
 Sets the timestamp offset for log formatting.
 
virtual std::string format (const LogRecord &record) const =0
 Formats a log record into a string.
 
virtual bool is_passthrough () const noexcept
 Indicates whether the formatter returns the message unchanged.
 

Detailed Description

Interface for formatting log records.

The ILogFormatter class defines an interface that any log formatter must implement. It provides a pure virtual function for formatting a log record into a string.

Definition at line 18 of file ILogFormatter.hpp.

Constructor & Destructor Documentation

◆ ~ILogFormatter()

virtual logit::ILogFormatter::~ILogFormatter ( )
virtualdefault

Member Function Documentation

◆ format()

virtual std::string logit::ILogFormatter::format ( const LogRecord & record) const
pure virtual

Formats a log record into a string.

This pure virtual function must be implemented by any class deriving from ILogFormatter. The implementation should format the log record into a human-readable or machine-readable string.

Parameters
recordThe log record to be formatted.
Returns
A string representing the formatted log message.

Implemented in logit::SimpleLogFormatter.

◆ is_passthrough()

virtual bool logit::ILogFormatter::is_passthrough ( ) const
inlinevirtualnoexcept

Indicates whether the formatter returns the message unchanged.

Passthrough formatters that simply forward the preformatted message can override this to enable fast-path handling without extra string copies.

Returns
True if the formatter is passthrough, false otherwise.

Definition at line 44 of file ILogFormatter.hpp.

◆ set_timestamp_offset()

virtual void logit::ILogFormatter::set_timestamp_offset ( int64_t offset_ms)
pure virtual

Sets the timestamp offset for log formatting.

This function allows setting a timezone offset in milliseconds, which will be used for adjusting timestamps in formatted log messages.

Parameters
offset_msTimezone offset in milliseconds.

Implemented in logit::SimpleLogFormatter.


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