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 usingDiagnosticsOutputStream.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
Delegateis active.- usdex::core::DiagnosticsOutputStream
Control the output stream to which diagnostics are logged.
Functions#
- void usdex::core::activateDiagnosticsDelegate()
Activates the
Delegateto specializeTfDiagnosticshandling.- void usdex::core::deactivateDiagnosticsDelegate()
Deactivates the
Delegateto restore defaultTfDiagnosticshandling.- DiagnosticsLevel usdex::core::getDiagnosticLevel(pxr::TfDiagnosticType code)
Get the
DiagnosticsLevelfor a givenTfDiagnosticType.- DiagnosticsLevel usdex::core::getDiagnosticsLevel()
Get the current
DiagnosticsLevelfor theDelegate.- DiagnosticsOutputStream usdex::core::getDiagnosticsOutputStream()
Get the current
DiagnosticsOutputStreamfor theDelegate.- bool usdex::core::isDiagnosticsDelegateActive()
Test whether the
Delegateis currently active.- void usdex::core::setDiagnosticsLevel(DiagnosticsLevel value)
Set the
DiagnosticsLevelfor theDelegateto filterTfDiagnosticsby severity.- void usdex::core::setDiagnosticsOutputStream(DiagnosticsOutputStream value)
Set the
DiagnosticsOutputStreamfor theDelegateto redirectTfDiagnosticsto different streams.