Suppress/Catch warning and error messages in python

Hello:
Is there a way to suppress warning messages in the terminal with either code or environment variable? I see there is a TfErrorMark that seems to allow me to catch error messages between points but I don’t seem to see a python binding for it. (22.05) Thank you!

You can write your own diagnostic delegate to filter warnings and errors–
see Universal Scene Description: pxr/usd/usdUtils/coalescingDiagnosticDelegate.h File Reference and
OpenUSD/pxr/usd/usdUtils/testenv/testUsdUtilsCoalescingDiagnosticDelegate.py at release · PixarAnimationStudios/OpenUSD · GitHub

In fact, the delegate Aaron identifies can be used to suppress output, instead of coalescing it.

Thank you both! I will look into the delegate.

As an alternative, on this thread we suggested that perhaps TF_WARN should integrate with the warning module via PyError_Warn. That would surface OpenUSD warnings as native python warnings (similar to how OpenUSD errors are surfaced as pyton exceptions) without having to rely on delegates to do filtering.

Integrating USD Tf.Warn with Python logging.Logger - Community / USD - Alliance for OpenUSD (aousd.org)