TSDuck Version 3.32-2780 (TSDuck - The MPEG Transport Stream Toolkit)
ts::ReportFile< MUTEX > Class Template Reference

A subclass of ts::Report which outputs messages in a text file. More...

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

Public Member Functions

 ReportFile (const UString &file_name, bool append=false, int max_severity=Severity::Info)
 Constructor using a named file. More...
 
 ReportFile (std::ostream &stream, int max_severity=0)
 Constructor using an open file stream. More...
 
virtual ~ReportFile () override
 Destructor.
 
bool debug () const
 Check if debugging is active. More...
 
void debug (const UChar *fmt, std::initializer_list< ArgMixIn > args)
 Report a debug message with a printf-like interface. More...
 
void debug (const UString &fmt, std::initializer_list< ArgMixIn > args)
 Report a debug message with a printf-like interface. More...
 
void debug (const UString &msg)
 Report a debug message. More...
 
void error (const UChar *fmt, std::initializer_list< ArgMixIn > args)
 Report an error message with a printf-like interface. More...
 
void error (const UString &fmt, std::initializer_list< ArgMixIn > args)
 Report an error message with a printf-like interface. More...
 
void error (const UString &msg)
 Report an error message. More...
 
void fatal (const UChar *fmt, std::initializer_list< ArgMixIn > args)
 Report a fatal error message with a printf-like interface. More...
 
void fatal (const UString &fmt, std::initializer_list< ArgMixIn > args)
 Report a fatal error message with a printf-like interface. More...
 
void fatal (const UString &msg)
 Report a fatal error message. More...
 
bool gotErrors () const
 Check if errors (or worse) were reported through this object. More...
 
void info (const UChar *fmt, std::initializer_list< ArgMixIn > args)
 Report an informational message with a printf-like interface. More...
 
void info (const UString &fmt, std::initializer_list< ArgMixIn > args)
 Report an informational message with a printf-like interface. More...
 
void info (const UString &msg)
 Report an informational message. More...
 
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. More...
 
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. More...
 
virtual void log (int severity, const UString &msg)
 Report a message with an explicit severity. More...
 
int maxSeverity () const
 Get maximum severity level. More...
 
virtual void raiseMaxSeverity (int level)
 Raise maximum severity level. More...
 
void resetErrors ()
 Reset the error indicator. More...
 
virtual void setMaxSeverity (int level)
 Set maximum severity level. More...
 
void severe (const UChar *fmt, std::initializer_list< ArgMixIn > args)
 Report a severe error message with a printf-like interface. More...
 
void severe (const UString &fmt, std::initializer_list< ArgMixIn > args)
 Report a severe error message with a printf-like interface. More...
 
void severe (const UString &msg)
 Report a severe error message. More...
 
bool verbose () const
 Check if verbose reporting is active. More...
 
void verbose (const UChar *fmt, std::initializer_list< ArgMixIn > args)
 Report a verbose message with a printf-like interface. More...
 
void verbose (const UString &fmt, std::initializer_list< ArgMixIn > args)
 Report a verbose message with a printf-like interface. More...
 
void verbose (const UString &msg)
 Report a verbose message. More...
 
void warning (const UChar *fmt, std::initializer_list< ArgMixIn > args)
 Report a warning message with a printf-like interface. More...
 
void warning (const UString &fmt, std::initializer_list< ArgMixIn > args)
 Report a warning message with a printf-like interface. More...
 
void warning (const UString &msg)
 Report a warning message. 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::ReportFile< MUTEX >

A subclass of ts::Report which outputs messages in a text file.

Reentrancy is supported though the template parameter MUTEX.

Template Parameters
MUTEXA subclass of ts::MutexInterface which is used to serialize access to the file. 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

◆ ReportFile() [1/2]

template<class MUTEX = NullMutex>
ts::ReportFile< MUTEX >::ReportFile ( const UString file_name,
bool  append = false,
int  max_severity = Severity::Info 
)

Constructor using a named file.

Parameters
[in]file_nameThe name of the file to create. If the file creation fails, a fatal error is generated with an error message on std::cerr. The file will be closed when this object is destroyed.
[in]appendIf true, append the messages at the end of the file. If false (the default), overwrite the file if it already existed.
[in]max_severityMaximum debug level to display. None by default.

◆ ReportFile() [2/2]

template<class MUTEX = NullMutex>
ts::ReportFile< MUTEX >::ReportFile ( std::ostream &  stream,
int  max_severity = 0 
)

Constructor using an open file stream.

Parameters
[in,out]streamA reference to an open output file stream to log the messages. The corresponding stream object must remain valid as long as this object exists. Typical valid values are std::cout and std::cerr.
[in]max_severityMaximum debug level to display. None by default.

Member Function Documentation

◆ writeLog()

template<class MUTEX = NullMutex>
virtual void ts::ReportFile< 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.

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: