Diagnostic Messages (Logs)#

Specialized handling of OpenUSD TfDiagnostic messages (logs).

The Tf module from OpenUSD provides various diagnostic logging abilities, including the ability to override the default message handler (which prints to stderr) with one or more custom handlers.

These functions can be used to control a specialized TfDiagnosticMgr::Delegate provided by OpenUSD Exchange. The primary advantages of this Delegate are:

  • Diagnostics can be filtered by DiagnosticsLevel.

  • Diagnostics can be redirected to stdout, stderr, or muted entirely using DiagnosticsOutputStream.

  • The message formatting is friendlier to end-users.

Note

Use of this Delegate is entirely optional and it is not activated by default when loading this module. To active it, client code must explicitly call activateDiagnosticsDelegate(). This is to allow clients to opt-in and to prevent double printing for clients that already have their own TfDiagnosticMgr::Delegate implementation.

Enumerations#

usdex::core::DiagnosticsLevel

Controls the diagnostics that will be emitted when the Delegate is active.

usdex::core::DiagnosticsOutputStream

Control the output stream to which diagnostics are logged.

Functions#

void usdex::core::activateDiagnosticsDelegate()

Activates the Delegate to specialize TfDiagnostics handling.

void usdex::core::deactivateDiagnosticsDelegate()

Deactivates the Delegate to restore default TfDiagnostics handling.

DiagnosticsLevel usdex::core::getDiagnosticLevel(pxr::TfDiagnosticType code)

Get the DiagnosticsLevel for a given TfDiagnosticType .

DiagnosticsLevel usdex::core::getDiagnosticsLevel()

Get the current DiagnosticsLevel for the Delegate .

DiagnosticsOutputStream usdex::core::getDiagnosticsOutputStream()

Get the current DiagnosticsOutputStream for the Delegate .

bool usdex::core::isDiagnosticsDelegateActive()

Test whether the Delegate is currently active.

void usdex::core::setDiagnosticsLevel(DiagnosticsLevel value)

Set the DiagnosticsLevel for the Delegate to filter TfDiagnostics by severity.

void usdex::core::setDiagnosticsOutputStream(DiagnosticsOutputStream value)

Set the DiagnosticsOutputStream for the Delegate to redirect TfDiagnostics to different streams.