TSDuck v3.38-3710
MPEG Transport Stream Toolkit
Loading...
Searching...
No Matches
ts::AsyncReport Class Reference

Asynchronous message report. More...

#include <tsAsyncReport.h>

Inheritance diagram for ts::AsyncReport:
Collaboration diagram for ts::AsyncReport:

Public Member Functions

 AsyncReport (int max_severity=Severity::Info, const AsyncReportArgs &args=AsyncReportArgs())
 Constructor.
 
virtual ~AsyncReport () override
 Destructor.
 
bool debug () const
 Check if debugging is active.
 
template<class... Args>
void debug (const UChar *fmt, Args &&... args)
 Report a debug message with a printf-like interface.
 
void debug (const UChar *msg)
 Report a debug message.
 
template<class... Args>
void debug (const UString &fmt, Args &&... args)
 Report a debug message with a printf-like interface.
 
void debug (const UString &msg)
 Report a debug message.
 
ReportdelegateReport (Report *report)
 Delegate message logging to another report object.
 
template<class... Args>
void error (const UChar *fmt, Args &&... args)
 Report an error message with a printf-like interface.
 
void error (const UChar *msg)
 Report an error message.
 
template<class... Args>
void error (const UString &fmt, Args &&... args)
 Report an error message with a printf-like interface.
 
void error (const UString &msg)
 Report an error message.
 
template<class... Args>
void fatal (const UChar *fmt, Args &&... args)
 Report a fatal error message with a printf-like interface.
 
void fatal (const UChar *msg)
 Report a fatal error message.
 
template<class... Args>
void fatal (const UString &fmt, Args &&... args)
 Report a fatal error message with a printf-like interface.
 
void fatal (const UString &msg)
 Report a fatal error message.
 
bool getSynchronous () const
 Check if synchronous mode is on.
 
bool getTimeStamp () const
 Check if time stamps are added in log messages.
 
bool gotErrors () const
 Check if errors (or worse) were reported through this object.
 
template<class... Args>
void info (const UChar *fmt, Args &&... args)
 Report an informational message with a printf-like interface.
 
void info (const UChar *msg)
 Report an informational message.
 
template<class... Args>
void info (const UString &fmt, Args &&... args)
 Report an informational message with a printf-like interface.
 
void info (const UString &msg)
 Report an informational message.
 
template<class... Args>
void log (int severity, const UChar *fmt, Args &&... args)
 Report a message with an explicit severity and a printf-like interface.
 
template<class... Args>
void log (int severity, const UString &fmt, Args &&... args)
 Report a message with an explicit severity and a printf-like interface.
 
void log (int severity, const UString &msg)
 Report a message with an explicit severity.
 
int maxSeverity () const
 Get maximum severity level.
 
void raiseMaxSeverity (int level, bool delegated=false)
 Raise maximum severity level.
 
UString reportPrefix () const
 Get the current prefix to display.
 
void resetErrors ()
 Reset the error indicator.
 
void setMaxSeverity (int level, bool delegated=false)
 Set maximum severity level.
 
void setReportPrefix (const UString &prefix)
 Set the prefix to display before each message.
 
void setSynchronous (bool on)
 Activate or deactivate the synchronous mode.
 
void setTimeStamp (bool on)
 Activate or deactivate time stamps in log messages.
 
template<class... Args>
void severe (const UChar *fmt, Args &&... args)
 Report a severe error message with a printf-like interface.
 
void severe (const UChar *msg)
 Report a severe error message.
 
template<class... Args>
void severe (const UString &fmt, Args &&... args)
 Report a severe error message with a printf-like interface.
 
void severe (const UString &msg)
 Report a severe error message.
 
void terminate ()
 Synchronously terminate the report thread.
 
bool verbose () const
 Check if verbose reporting is active.
 
template<class... Args>
void verbose (const UChar *fmt, Args &&... args)
 Report a verbose message with a printf-like interface.
 
void verbose (const UChar *msg)
 Report a verbose message.
 
template<class... Args>
void verbose (const UString &fmt, Args &&... args)
 Report a verbose message with a printf-like interface.
 
void verbose (const UString &msg)
 Report a verbose message.
 
template<class... Args>
void warning (const UChar *fmt, Args &&... args)
 Report a warning message with a printf-like interface.
 
void warning (const UChar *msg)
 Report a warning error message.
 
template<class... Args>
void warning (const UString &fmt, Args &&... args)
 Report a warning message with a printf-like interface.
 
void warning (const UString &msg)
 Report a warning error message.
 

Protected Member Functions

virtual void asyncThreadCompleted ()
 This method is called in the context of the asynchronous logging thread when it completes.
 
virtual void asyncThreadLog (int severity, const UString &message)
 This method is called in the context of the asynchronous logging thread to log a message.
 
virtual void asyncThreadStarted ()
 This method is called in the context of the asynchronous logging thread when it starts.
 

Detailed Description

Asynchronous message report.

This class logs messages asynchronously. Each time a message is logged, the message is queued into an internal buffer and control returns immediately to the caller without waiting. The messages are logged later in one single low-priority thread.

In case of a huge amount of errors, there is no avalanche effect. If a caller cannot immediately enqueue a message or if the internal queue of messages is full, the message is dropped. In other words, reporting messages is guaranteed to never block, slow down or crash the application. Messages are dropped when necessary to avoid that kind of problem.

Messages are displayed on the standard error device by default.

Constructor & Destructor Documentation

◆ AsyncReport()

ts::AsyncReport::AsyncReport ( int  max_severity = Severity::Info,
const AsyncReportArgs args = AsyncReportArgs() 
)

Constructor.

The default initial report level is Info.

Parameters
[in]max_severitySet initial level report to that level.
[in]argsInitial parameters.
See also
AsyncReportArgs

Member Function Documentation

◆ setTimeStamp()

void ts::AsyncReport::setTimeStamp ( bool  on)
inline

Activate or deactivate time stamps in log messages.

Parameters
[in]onIf true, time stamps are added to all messages.

◆ getTimeStamp()

bool ts::AsyncReport::getTimeStamp ( ) const
inline

Check if time stamps are added in log messages.

Returns
True if time stamps are added in log messages.

◆ setSynchronous()

void ts::AsyncReport::setSynchronous ( bool  on)
inline

Activate or deactivate the synchronous mode.

Parameters
[in]onIf true, the delivery of messages is synchronous. No message is dropped, all messages are delivered.

◆ getSynchronous()

bool ts::AsyncReport::getSynchronous ( ) const
inline

Check if synchronous mode is on.

Returns
True if the delivery of messages is synchronous.

◆ terminate()

void ts::AsyncReport::terminate ( )

Synchronously terminate the report thread.

Automatically performed in destructor.

◆ asyncThreadStarted()

virtual void ts::AsyncReport::asyncThreadStarted ( )
protectedvirtual

This method is called in the context of the asynchronous logging thread when it starts.

The default implementation does nothing. Subclasses may override it to get notified.

◆ asyncThreadLog()

virtual void ts::AsyncReport::asyncThreadLog ( int  severity,
const UString message 
)
protectedvirtual

This method is called in the context of the asynchronous logging thread to log a message.

The default implementation prints the message on the standard error.

Parameters
[in]severitySeverity level of the message.
[in]messageThe message line to log.

◆ asyncThreadCompleted()

virtual void ts::AsyncReport::asyncThreadCompleted ( )
protectedvirtual

This method is called in the context of the asynchronous logging thread when it completes.

The default implementation does nothing. Subclasses may override it to get notified.

◆ setMaxSeverity()

void ts::Report::setMaxSeverity ( int  level,
bool  delegated = false 
)
inherited

Set maximum severity level.

Messages with higher severities are not reported.

Parameters
[in]levelSet report to that level.
[in]delegatedPropagate the severity to delegated reports.

◆ raiseMaxSeverity()

void ts::Report::raiseMaxSeverity ( int  level,
bool  delegated = false 
)
inherited

Raise maximum severity level.

The severity can only be increased (more verbose, more debug), never decreased.

Parameters
[in]levelSet report at least to that level.
[in]delegatedPropagate the severity to delegated reports.

◆ maxSeverity()

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

Get maximum severity level.

Returns
Current maximum debug level.

◆ gotErrors()

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

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

Errors which were reported through delegated reports are ignored.

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

◆ resetErrors()

void ts::Report::resetErrors ( )
inlineinherited

Reset the error indicator.

See also
gotErrors()

◆ setReportPrefix()

void ts::Report::setReportPrefix ( const UString prefix)
inlineinherited

Set the prefix to display before each message.

Parameters
[in]prefixThe prefix to prepend to all messages.

◆ reportPrefix()

UString ts::Report::reportPrefix ( ) const
inlineinherited

Get the current prefix to display.

Returns
The current prefix to display.

◆ delegateReport()

Report * ts::Report::delegateReport ( Report report)
inherited

Delegate message logging to another report object.

Parameters
[in]reportNew report object to which messages are delegated. Use nullptr to remove the delegation and return to normal logging.
Returns
Previous delegate report, return a null pointer if there was no previous delegate.

◆ debug() [1/5]

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

Check if debugging is active.

Returns
True if current reporting level is Debug or higher.

◆ debug() [2/5]

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

Report a debug message.

Parameters
[in]msgMessage line.

◆ debug() [3/5]

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

Report a debug message.

Parameters
[in]msgMessage line.

◆ debug() [4/5]

template<class... Args>
void ts::Report::debug ( const UChar fmt,
Args &&...  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() [5/5]

template<class... Args>
void ts::Report::debug ( const UString fmt,
Args &&...  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/5]

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

Check if verbose reporting is active.

Returns
True if current reporting level is Verbose or higher.

◆ verbose() [2/5]

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

Report a verbose message.

Parameters
[in]msgMessage line.

◆ verbose() [3/5]

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

Report a verbose message.

Parameters
[in]msgMessage line.

◆ verbose() [4/5]

template<class... Args>
void ts::Report::verbose ( const UChar fmt,
Args &&...  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() [5/5]

template<class... Args>
void ts::Report::verbose ( const UString fmt,
Args &&...  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]

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

Report a message with an explicit severity.

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

◆ log() [2/3]

template<class... Args>
void ts::Report::log ( int  severity,
const UChar fmt,
Args &&...  args 
)
inlineinherited

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]

template<class... Args>
void ts::Report::log ( int  severity,
const UString fmt,
Args &&...  args 
)
inlineinherited

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/4]

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

Report a fatal error message.

Parameters
[in]msgMessage line.

◆ fatal() [2/4]

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

Report a fatal error message.

Parameters
[in]msgMessage line.

◆ fatal() [3/4]

template<class... Args>
void ts::Report::fatal ( const UChar fmt,
Args &&...  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() [4/4]

template<class... Args>
void ts::Report::fatal ( const UString fmt,
Args &&...  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/4]

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

Report a severe error message.

Parameters
[in]msgMessage line.

◆ severe() [2/4]

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

Report a severe error message.

Parameters
[in]msgMessage line.

◆ severe() [3/4]

template<class... Args>
void ts::Report::severe ( const UChar fmt,
Args &&...  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() [4/4]

template<class... Args>
void ts::Report::severe ( const UString fmt,
Args &&...  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/4]

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

Report an error message.

Parameters
[in]msgMessage line.

◆ error() [2/4]

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

Report an error message.

Parameters
[in]msgMessage line.

◆ error() [3/4]

template<class... Args>
void ts::Report::error ( const UChar fmt,
Args &&...  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() [4/4]

template<class... Args>
void ts::Report::error ( const UString fmt,
Args &&...  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/4]

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

Report a warning error message.

Parameters
[in]msgMessage line.

◆ warning() [2/4]

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

Report a warning error message.

Parameters
[in]msgMessage line.

◆ warning() [3/4]

template<class... Args>
void ts::Report::warning ( const UChar fmt,
Args &&...  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() [4/4]

template<class... Args>
void ts::Report::warning ( const UString fmt,
Args &&...  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/4]

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

Report an informational message.

Parameters
[in]msgMessage line.

◆ info() [2/4]

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

Report an informational message.

Parameters
[in]msgMessage line.

◆ info() [3/4]

template<class... Args>
void ts::Report::info ( const UChar fmt,
Args &&...  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() [4/4]

template<class... Args>
void ts::Report::info ( const UString fmt,
Args &&...  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: