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
Delegate
is active.- usdex::core::DiagnosticsOutputStream
Control the output stream to which diagnostics are logged.
Functions#
- void usdex::core::activateDiagnosticsDelegate()
Activates the
Delegate
to specializeTfDiagnostics
handling.- void usdex::core::deactivateDiagnosticsDelegate()
Deactivates the
Delegate
to restore defaultTfDiagnostics
handling.- DiagnosticsLevel usdex::core::getDiagnosticsLevel()
Get the current
DiagnosticsLevel
for theDelegate
.- DiagnosticsOutputStream usdex::core::getDiagnosticsOutputStream()
Get the current
DiagnosticsOutputStream
for theDelegate
.- bool usdex::core::isDiagnosticsDelegateActive()
Test whether the
Delegate
is currently active.- void usdex::core::setDiagnosticsLevel(DiagnosticsLevel value)
Set the
DiagnosticsLevel
for theDelegate
to filterTfDiagnostics
by severity.- void usdex::core::setDiagnosticsOutputStream(DiagnosticsOutputStream value)
Set the
DiagnosticsOutputStream
for theDelegate
to redirectTfDiagnostics
to different streams.
Enumerations#
-
enum class usdex::core::DiagnosticsLevel#
Controls the diagnostics that will be emitted when the
Delegate
is active.Values:
-
enumerator eFatal#
Only
TF_FATAL
are emitted.
-
enumerator eError#
Emit
TF_ERROR
andTF_FATAL
, but suppressTF_WARN
andTF_STATUS
diagnostics.
-
enumerator eWarning#
Emit
TF_WARN
,TF_ERROR
, andTF_FATAL
, but suppressTF_STATUS
diagnostics.
-
enumerator eStatus#
All diagnostics are emitted.
-
enumerator eFatal#
Functions#
-
void usdex::core::activateDiagnosticsDelegate()#
Activates the
Delegate
to specializeTfDiagnostics
handling.When active, the
Delegate
replaces the defaultTfDiagnosticMgr
printing 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
Delegate
to restore defaultTfDiagnostics
handling.When deactivated, the default
TfDiagnosticMgr
printing is restored, unless some otherDelegate
is still active. See Diagnostic Messages (Logs) for more details.
-
DiagnosticsLevel usdex::core::getDiagnosticsLevel()#
Get the current
DiagnosticsLevel
for 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
DiagnosticsLevel
for theDelegate
.
-
DiagnosticsOutputStream usdex::core::getDiagnosticsOutputStream()#
Get the current
DiagnosticsOutputStream
for 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
DiagnosticsOutputStream
for theDelegate
.
-
bool usdex::core::isDiagnosticsDelegateActive()#
Test whether the
Delegate
is currently active.When active, the
Delegate
replaces the defaultTfDiagnosticMgr
printing with a more customized result. See Diagnostic Messages (Logs) for more details.- Returns:
Whether the
Delegate
is active
-
void usdex::core::setDiagnosticsLevel(DiagnosticsLevel value)#
Set the
DiagnosticsLevel
for theDelegate
to filterTfDiagnostics
by 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
DiagnosticsLevel
that should be emitted.
- void usdex::core::setDiagnosticsOutputStream(
- DiagnosticsOutputStream value,
Set the
DiagnosticsOutputStream
for theDelegate
to redirectTfDiagnostics
to 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.