TSDuck v3.37-3645
MPEG Transport Stream Toolkit
Loading...
Searching...
No Matches
ts::ReportBuffer< SAFETY > Class Template Reference

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

#include <tsReportBuffer.h>

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

Public Types

using MutexType = typename ThreadSafetyMutex< SAFETY >::type
 Generic definition of the mutex for this class.
 

Public Member Functions

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

Protected Member Functions

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

Protected Attributes

volatile int _max_severity = Severity::Info
 Debug level is accessible to subclasses.
 

Detailed Description

template<ThreadSafety SAFETY>
class ts::ReportBuffer< SAFETY >

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

Reentrancy is supported though the template parameter SAFETY.

Template Parameters
SAFETYThe required type of thread-safety.

Constructor & Destructor Documentation

◆ ReportBuffer()

template<ThreadSafety SAFETY>
ts::ReportBuffer< SAFETY >::ReportBuffer ( int  max_severity = Severity::Info)
inline

Constructor.

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

Member Function Documentation

◆ messages()

template<ts::ThreadSafety SAFETY>
ts::UString ts::ReportBuffer< SAFETY >::messages ( ) 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.

◆ empty()

template<ts::ThreadSafety SAFETY>
bool ts::ReportBuffer< SAFETY >::empty ( ) const

Check if the content of the internal buffer is empty.

Returns
True if no message was logged, false otherwise.

◆ writeLog()

template<ts::ThreadSafety SAFETY>
void ts::ReportBuffer< SAFETY >::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.

Reimplemented in ts::ReportWithPrefix.

◆ 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,
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,
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,
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,
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,
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,
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,
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,
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,
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,
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,
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,
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,
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,
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,
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,
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()

◆ gotErrors()

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

Check if errors (or worse) were reported through this object.

Returns
True if errors (or worse) were reported through this object.

◆ resetErrors()

void ts::Report::resetErrors ( )
inlineinherited

Reset the error indicator.

See also
gotErrors()

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