![]() |
TSDuck
v3.35-3218
MPEG Transport Stream Toolkit
|
Asynchronous message report. More...
Public Member Functions | |
AsyncReport (int max_severity=Severity::Info, const AsyncReportArgs &args=AsyncReportArgs()) | |
Constructor. More... | |
virtual | ~AsyncReport () 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 | getSynchronous () const |
Check if synchronous mode is on. More... | |
bool | getTimeStamp () const |
Check if time stamps are added in log messages. 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 | setSynchronous (bool on) |
Activate or deactivate the synchronous mode. More... | |
void | setTimeStamp (bool on) |
Activate or deactivate time stamps in log messages. 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... | |
void | terminate () |
Synchronously terminate the report thread. 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 | asyncThreadCompleted () |
This method is called in the context of the asynchronous logging thread when it completes. More... | |
virtual void | asyncThreadLog (int severity, const UString &message) |
This method is called in the context of the asynchronous logging thread to log a message. More... | |
virtual void | asyncThreadStarted () |
This method is called in the context of the asynchronous logging thread when it starts. More... | |
Protected Attributes | |
volatile int | _max_severity |
Debug level is accessible to subclasses. | |
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.
ts::AsyncReport::AsyncReport | ( | int | max_severity = Severity::Info , |
const AsyncReportArgs & | args = AsyncReportArgs() |
||
) |
Constructor.
The default initial report level is Info.
[in] | max_severity | Set initial level report to that level. |
[in] | args | Initial parameters. |
|
inline |
Activate or deactivate time stamps in log messages.
[in] | on | If true, time stamps are added to all messages. |
|
inline |
Check if time stamps are added in log messages.
|
inline |
Activate or deactivate the synchronous mode.
[in] | on | If true, the delivery of messages is synchronous. No message is dropped, all messages are delivered. |
|
inline |
Check if synchronous mode is on.
void ts::AsyncReport::terminate | ( | ) |
Synchronously terminate the report thread.
Automatically performed in destructor.
|
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.
|
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.
[in] | severity | Severity level of the message. |
[in] | message | The message line to log. |
|
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.
|
virtualinherited |
Set maximum severity level.
Messages with higher severities are not reported.
[in] | level | Set report to that level. |
Reimplemented in ts::ReportWithPrefix.
|
virtualinherited |
Raise maximum severity level.
[in] | level | Set report at least to that level. |
Reimplemented in ts::Args.
|
inlineinherited |
Get maximum severity level.
|
inlineinherited |
Check if debugging is active.
|
inlineinherited |
Report a debug message.
[in] | msg | Message text. |
|
inlineinherited |
Report a debug message with a printf-like interface.
[in] | fmt | Format string with embedded '%' sequences. |
[in] | args | List of arguments to substitute in the format string. |
|
inlineinherited |
Report a debug message with a printf-like interface.
[in] | fmt | Format string with embedded '%' sequences. |
[in] | args | List of arguments to substitute in the format string. |
|
inlineinherited |
Check if verbose reporting is active.
|
inlineinherited |
Report a verbose message.
[in] | msg | Message text. |
|
inlineinherited |
Report a verbose message with a printf-like interface.
[in] | fmt | Format string with embedded '%' sequences. |
[in] | args | List of arguments to substitute in the format string. |
|
inlineinherited |
Report a verbose message with a printf-like interface.
[in] | fmt | Format string with embedded '%' sequences. |
[in] | args | List of arguments to substitute in the format string. |
|
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.
[in] | severity | Message severity. |
[in] | msg | Message text. |
|
virtualinherited |
Report a message with an explicit severity and a printf-like interface.
[in] | severity | Message severity. |
[in] | fmt | Format string with embedded '%' sequences. |
[in] | args | List of arguments to substitute in the format string. |
|
virtualinherited |
Report a message with an explicit severity and a printf-like interface.
[in] | severity | Message severity. |
[in] | fmt | Format string with embedded '%' sequences. |
[in] | args | List of arguments to substitute in the format string. |
|
inlineinherited |
Report a fatal error message.
[in] | msg | Message text. |
|
inlineinherited |
Report a fatal error message with a printf-like interface.
[in] | fmt | Format string with embedded '%' sequences. |
[in] | args | List of arguments to substitute in the format string. |
|
inlineinherited |
Report a fatal error message with a printf-like interface.
[in] | fmt | Format string with embedded '%' sequences. |
[in] | args | List of arguments to substitute in the format string. |
|
inlineinherited |
Report a severe error message.
[in] | msg | Message text. |
|
inlineinherited |
Report a severe error message with a printf-like interface.
[in] | fmt | Format string with embedded '%' sequences. |
[in] | args | List of arguments to substitute in the format string. |
|
inlineinherited |
Report a severe error message with a printf-like interface.
[in] | fmt | Format string with embedded '%' sequences. |
[in] | args | List of arguments to substitute in the format string. |
|
inlineinherited |
Report an error message.
[in] | msg | Message text. |
|
inlineinherited |
Report an error message with a printf-like interface.
[in] | fmt | Format string with embedded '%' sequences. |
[in] | args | List of arguments to substitute in the format string. |
|
inlineinherited |
Report an error message with a printf-like interface.
[in] | fmt | Format string with embedded '%' sequences. |
[in] | args | List of arguments to substitute in the format string. |
|
inlineinherited |
Report a warning message.
[in] | msg | Message text. |
|
inlineinherited |
Report a warning message with a printf-like interface.
[in] | fmt | Format string with embedded '%' sequences. |
[in] | args | List of arguments to substitute in the format string. |
|
inlineinherited |
Report a warning message with a printf-like interface.
[in] | fmt | Format string with embedded '%' sequences. |
[in] | args | List of arguments to substitute in the format string. |
|
inlineinherited |
Report an informational message.
[in] | msg | Message text. |
Report an informational message with a printf-like interface.
[in] | fmt | Format string with embedded '%' sequences. |
[in] | args | List of arguments to substitute in the format string. |
|
inlineinherited |
Report an informational message with a printf-like interface.
[in] | fmt | Format string with embedded '%' sequences. |
[in] | args | List of arguments to substitute in the format string. |
|
inlineinherited |
Check if errors (or worse) were reported through this object.
|
inlineinherited |
Reset the error indicator.