TSDuck Version 3.16-1064 (TSDuck - The MPEG Transport Stream Toolkit)
ts::ReportBuffer< MUTEX > Class Template Reference

A subclass of ts::Report which logs all messages in an internal buffer. More...

Inheritance diagram for ts::ReportBuffer< MUTEX >:
Collaboration diagram for ts::ReportBuffer< MUTEX >:

Public Member Functions

 ReportBuffer (int max_severity=Severity::Info)
 Constructor. More...
 
bool debug () const
 Check if debugging is active. More...
 
void debug (const UString &msg)
 Report a debug message. More...
 
void debug (const UChar *fmt, const std::initializer_list< ArgMixIn > &args)
 Report a debug message with a printf-like interface. More...
 
void debug (const UString &fmt, const std::initializer_list< ArgMixIn > &args)
 Report a debug message with a printf-like interface. More...
 
bool emptyMessages () const
 Check if the content of the internal buffer is empty. More...
 
void error (const UString &msg)
 Report an error message. More...
 
void error (const UChar *fmt, const std::initializer_list< ArgMixIn > &args)
 Report an error message with a printf-like interface. More...
 
void error (const UString &fmt, const std::initializer_list< ArgMixIn > &args)
 Report an error message with a printf-like interface. More...
 
void fatal (const UString &msg)
 Report a fatal error message. More...
 
void fatal (const UChar *fmt, const std::initializer_list< ArgMixIn > &args)
 Report a fatal error message with a printf-like interface. More...
 
void fatal (const UString &fmt, const std::initializer_list< ArgMixIn > &args)
 Report a fatal error message with a printf-like interface. More...
 
UString getMessages () const
 Get the content of the internal buffer. More...
 
void info (const UString &msg)
 Report an informational message. More...
 
void info (const UChar *fmt, const std::initializer_list< ArgMixIn > &args)
 Report an informational message with a printf-like interface. More...
 
void info (const UString &fmt, const std::initializer_list< ArgMixIn > &args)
 Report an informational message with a printf-like interface. More...
 
virtual void log (int severity, const UString &msg)
 Report a message with an explicit severity. More...
 
virtual void log (int severity, const UChar *fmt, const std::initializer_list< ArgMixIn > &args)
 Report a message with an explicit severity and a printf-like interface. More...
 
virtual void log (int severity, const UString &fmt, const std::initializer_list< ArgMixIn > &args)
 Report a message with an explicit severity and a printf-like interface. More...
 
int maxSeverity () const
 Get maximum severity level. More...
 
virtual void raiseMaxSeverity (int level)
 Raise maximum severity level. More...
 
void resetMessages ()
 Reset the content of the internal buffer.
 
virtual void setMaxSeverity (int level)
 Set maximum severity level. More...
 
void severe (const UString &msg)
 Report a severe error message. More...
 
void severe (const UChar *fmt, const std::initializer_list< ArgMixIn > &args)
 Report a severe error message with a printf-like interface. More...
 
void severe (const UString &fmt, const std::initializer_list< ArgMixIn > &args)
 Report a severe error message with a printf-like interface. More...
 
bool verbose () const
 Check if verbose reporting is active. More...
 
void verbose (const UString &msg)
 Report a verbose message. More...
 
void verbose (const UChar *fmt, const std::initializer_list< ArgMixIn > &args)
 Report a verbose message with a printf-like interface. More...
 
void verbose (const UString &fmt, const std::initializer_list< ArgMixIn > &args)
 Report a verbose message with a printf-like interface. More...
 
void warning (const UString &msg)
 Report a warning message. More...
 
void warning (const UChar *fmt, const std::initializer_list< ArgMixIn > &args)
 Report a warning message with a printf-like interface. More...
 
void warning (const UString &fmt, const std::initializer_list< ArgMixIn > &args)
 Report a warning message with a printf-like interface. More...
 

Protected Member Functions

virtual void writeLog (int severity, const UString &message) override
 Actual message reporting method. More...
 

Protected Attributes

volatile int _max_severity
 Debug level is accessible to subclasses.
 

Detailed Description

template<class MUTEX = NullMutex>
class ts::ReportBuffer< MUTEX >

A subclass of ts::Report which logs all messages in an internal buffer.

Reentrancy is supported though the template parameter MUTEX.

Template Parameters
MUTEXA subclass of ts::MutexInterface which is used to serialize access to the buffer. By default, the class ts::NullMutex is used, meaning that there is no synchronization on the file. Multi-threaded applications must use an appropriate mutex class, typically ts::Mutex.

Constructor & Destructor Documentation

◆ ReportBuffer()

template<class MUTEX = NullMutex>
ts::ReportBuffer< MUTEX >::ReportBuffer ( int  max_severity = Severity::Info)

Constructor.

Parameters
[in]max_severityMaximum debug level to display. None by default.

Member Function Documentation

◆ getMessages()

template<class MUTEX = NullMutex>
UString ts::ReportBuffer< MUTEX >::getMessages ( ) const

Get the content of the internal buffer.

Returns
All messages which were logged. Consecutive messages are separated by a newline character ('
') but there is no newline after the last line.

◆ emptyMessages()

template<class MUTEX = NullMutex>
bool ts::ReportBuffer< MUTEX >::emptyMessages ( ) const

Check if the content of the internal buffer is empty.

Returns
True if no message was logged, false otherwise.

◆ writeLog()

template<class MUTEX = NullMutex>
virtual void ts::ReportBuffer< MUTEX >::writeLog ( int  severity,
const UString msg 
)
overrideprotectedvirtual

Actual message reporting method.

Must be implemented in actual classes. The method is called only when a message passed the severity filter. It is not necessary to recheck severity inside the method.

Parameters
[in]severityMessage severity.
[in]msgMessage text.

Implements ts::Report.

◆ setMaxSeverity()

virtual void ts::Report::setMaxSeverity ( int  level)
virtualinherited

Set maximum severity level.

Messages with higher severities are not reported.

Parameters
[in]levelSet report to that level.

◆ raiseMaxSeverity()

virtual void ts::Report::raiseMaxSeverity ( int  level)
virtualinherited

Raise maximum severity level.

Parameters
[in]levelSet report at least to that level.

Reimplemented in ts::Args.

◆ maxSeverity()

int ts::Report::maxSeverity ( ) const
inlineinherited

Get maximum severity level.

Returns
Current maximum debug level.

◆ debug() [1/4]

bool ts::Report::debug ( ) const
inlineinherited

Check if debugging is active.

Returns
True if current reporting level is Debug or higher.

◆ debug() [2/4]

void ts::Report::debug ( const UString msg)
inlineinherited

Report a debug message.

Parameters
[in]msgMessage text.

◆ debug() [3/4]

void ts::Report::debug ( const UChar fmt,
const std::initializer_list< ArgMixIn > &  args 
)
inlineinherited

Report a debug message with a printf-like interface.

Parameters
[in]fmtFormat string with embedded '%' sequences.
[in]argsList of arguments to substitute in the format string.
See also
UString::format()

◆ debug() [4/4]

void ts::Report::debug ( const UString fmt,
const std::initializer_list< ArgMixIn > &  args 
)
inlineinherited

Report a debug message with a printf-like interface.

Parameters
[in]fmtFormat string with embedded '%' sequences.
[in]argsList of arguments to substitute in the format string.
See also
UString::format()

◆ verbose() [1/4]

bool ts::Report::verbose ( ) const
inlineinherited

Check if verbose reporting is active.

Returns
True if current reporting level is Verbose or higher.

◆ verbose() [2/4]

void ts::Report::verbose ( const UString msg)
inlineinherited

Report a verbose message.

Parameters
[in]msgMessage text.

◆ verbose() [3/4]

void ts::Report::verbose ( const UChar fmt,
const std::initializer_list< ArgMixIn > &  args 
)
inlineinherited

Report a verbose message with a printf-like interface.

Parameters
[in]fmtFormat string with embedded '%' sequences.
[in]argsList of arguments to substitute in the format string.
See also
UString::format()

◆ verbose() [4/4]

void ts::Report::verbose ( const UString fmt,
const std::initializer_list< ArgMixIn > &  args 
)
inlineinherited

Report a verbose message with a printf-like interface.

Parameters
[in]fmtFormat string with embedded '%' sequences.
[in]argsList of arguments to substitute in the format string.
See also
UString::format()

◆ log() [1/3]

virtual void ts::Report::log ( int  severity,
const UString msg 
)
virtualinherited

Report a message with an explicit severity.

This method is the central reporting point. If filters the severity and drops the message if severity is higher than maxSeverity().

Subclasses should override writeLog() to implement a specific reporting device. It is not necessary to override log() unless the subclass needs to implement a different severity filtering policy.

Parameters
[in]severityMessage severity.
[in]msgMessage text.

◆ log() [2/3]

virtual void ts::Report::log ( int  severity,
const UChar fmt,
const std::initializer_list< ArgMixIn > &  args 
)
virtualinherited

Report a message with an explicit severity and a printf-like interface.

Parameters
[in]severityMessage severity.
[in]fmtFormat string with embedded '%' sequences.
[in]argsList of arguments to substitute in the format string.
See also
UString::format()

◆ log() [3/3]

virtual void ts::Report::log ( int  severity,
const UString fmt,
const std::initializer_list< ArgMixIn > &  args 
)
virtualinherited

Report a message with an explicit severity and a printf-like interface.

Parameters
[in]severityMessage severity.
[in]fmtFormat string with embedded '%' sequences.
[in]argsList of arguments to substitute in the format string.
See also
UString::format()

◆ fatal() [1/3]

void ts::Report::fatal ( const UString msg)
inlineinherited

Report a fatal error message.

Parameters
[in]msgMessage text.

◆ fatal() [2/3]

void ts::Report::fatal ( const UChar fmt,
const std::initializer_list< ArgMixIn > &  args 
)
inlineinherited

Report a fatal error message with a printf-like interface.

Parameters
[in]fmtFormat string with embedded '%' sequences.
[in]argsList of arguments to substitute in the format string.
See also
UString::format()

◆ fatal() [3/3]

void ts::Report::fatal ( const UString fmt,
const std::initializer_list< ArgMixIn > &  args 
)
inlineinherited

Report a fatal error message with a printf-like interface.

Parameters
[in]fmtFormat string with embedded '%' sequences.
[in]argsList of arguments to substitute in the format string.
See also
UString::format()

◆ severe() [1/3]

void ts::Report::severe ( const UString msg)
inlineinherited

Report a severe error message.

Parameters
[in]msgMessage text.

◆ severe() [2/3]

void ts::Report::severe ( const UChar fmt,
const std::initializer_list< ArgMixIn > &  args 
)
inlineinherited

Report a severe error message with a printf-like interface.

Parameters
[in]fmtFormat string with embedded '%' sequences.
[in]argsList of arguments to substitute in the format string.
See also
UString::format()

◆ severe() [3/3]

void ts::Report::severe ( const UString fmt,
const std::initializer_list< ArgMixIn > &  args 
)
inlineinherited

Report a severe error message with a printf-like interface.

Parameters
[in]fmtFormat string with embedded '%' sequences.
[in]argsList of arguments to substitute in the format string.
See also
UString::format()

◆ error() [1/3]

void ts::Report::error ( const UString msg)
inlineinherited

Report an error message.

Parameters
[in]msgMessage text.

◆ error() [2/3]

void ts::Report::error ( const UChar fmt,
const std::initializer_list< ArgMixIn > &  args 
)
inlineinherited

Report an error message with a printf-like interface.

Parameters
[in]fmtFormat string with embedded '%' sequences.
[in]argsList of arguments to substitute in the format string.
See also
UString::format()

◆ error() [3/3]

void ts::Report::error ( const UString fmt,
const std::initializer_list< ArgMixIn > &  args 
)
inlineinherited

Report an error message with a printf-like interface.

Parameters
[in]fmtFormat string with embedded '%' sequences.
[in]argsList of arguments to substitute in the format string.
See also
UString::format()

◆ warning() [1/3]

void ts::Report::warning ( const UString msg)
inlineinherited

Report a warning message.

Parameters
[in]msgMessage text.

◆ warning() [2/3]

void ts::Report::warning ( const UChar fmt,
const std::initializer_list< ArgMixIn > &  args 
)
inlineinherited

Report a warning message with a printf-like interface.

Parameters
[in]fmtFormat string with embedded '%' sequences.
[in]argsList of arguments to substitute in the format string.
See also
UString::format()

◆ warning() [3/3]

void ts::Report::warning ( const UString fmt,
const std::initializer_list< ArgMixIn > &  args 
)
inlineinherited

Report a warning message with a printf-like interface.

Parameters
[in]fmtFormat string with embedded '%' sequences.
[in]argsList of arguments to substitute in the format string.
See also
UString::format()

◆ info() [1/3]

void ts::Report::info ( const UString msg)
inlineinherited

Report an informational message.

Parameters
[in]msgMessage text.

◆ info() [2/3]

void ts::Report::info ( const UChar fmt,
const std::initializer_list< ArgMixIn > &  args 
)
inlineinherited

Report an informational message with a printf-like interface.

Parameters
[in]fmtFormat string with embedded '%' sequences.
[in]argsList of arguments to substitute in the format string.
See also
UString::format()

◆ info() [3/3]

void ts::Report::info ( const UString fmt,
const std::initializer_list< ArgMixIn > &  args 
)
inlineinherited

Report an informational message with a printf-like interface.

Parameters
[in]fmtFormat string with embedded '%' sequences.
[in]argsList of arguments to substitute in the format string.
See also
UString::format()

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