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::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.
Enumerations#
-
enum class usdex::core::DiagnosticsLevel#
Controls the diagnostics that will be emitted when the
Delegateis active.Values:
-
enumerator eFatal#
Only
TF_FATALare emitted.
-
enumerator eError#
Emit
TF_ERRORandTF_FATAL, but suppressTF_WARNandTF_STATUSdiagnostics.
-
enumerator eWarning#
Emit
TF_WARN,TF_ERROR, andTF_FATAL, but suppressTF_STATUSdiagnostics.
-
enumerator eStatus#
All diagnostics are emitted.
-
enumerator eFatal#
Functions#
-
void usdex::core::activateDiagnosticsDelegate()#
Activates the
Delegateto specializeTfDiagnosticshandling.When active, the
Delegatereplaces the defaultTfDiagnosticMgrprinting with a more customized result. See Diagnostic Messages (Logs) for more details.Note
The delegate is not active when this module loads. Clients must explicitly call this function to activate it.
-
void usdex::core::deactivateDiagnosticsDelegate()#
Deactivates the
Delegateto restore defaultTfDiagnosticshandling.When deactivated, the default
TfDiagnosticMgrprinting is restored, unless some otherDelegateis still active. See Diagnostic Messages (Logs) for more details.
-
DiagnosticsLevel usdex::core::getDiagnosticsLevel()#
Get the current
DiagnosticsLevelfor theDelegate.This can be called at any time, but the filtering will only take affect after calling
activateDiagnosticsDelegate(). See Diagnostic Messages (Logs) for more details.- Returns:
The current
DiagnosticsLevelfor theDelegate.
-
DiagnosticsOutputStream usdex::core::getDiagnosticsOutputStream()#
Get the current
DiagnosticsOutputStreamfor theDelegate.This can be called at any time, but will only take affect after calling
activateDiagnosticsDelegate(). See Diagnostic Messages (Logs) for more details.- Returns:
The current
DiagnosticsOutputStreamfor theDelegate.
-
bool usdex::core::isDiagnosticsDelegateActive()#
Test whether the
Delegateis currently active.When active, the
Delegatereplaces the defaultTfDiagnosticMgrprinting with a more customized result. See Diagnostic Messages (Logs) for more details.- Returns:
Whether the
Delegateis active
-
void usdex::core::setDiagnosticsLevel(DiagnosticsLevel value)#
Set the
DiagnosticsLevelfor theDelegateto filterTfDiagnosticsby severity.This can be called at any time, but the filtering will only take affect after calling
activateDiagnosticsDelegate(). See Diagnostic Messages (Logs) for more details.- Parameters:
value – The highest severity
DiagnosticsLevelthat should be emitted.
- void usdex::core::setDiagnosticsOutputStream(
- DiagnosticsOutputStream value,
Set the
DiagnosticsOutputStreamfor theDelegateto redirectTfDiagnosticsto different streams.This can be called at any time, but will only take affect after calling
activateDiagnosticsDelegate(). See Diagnostic Messages (Logs) for more details.- Parameters:
value – The stream to which all diagnostics should be emitted.