Catch Warning message

Hi,
How can I catch a warning message, for example:
/usr/local/lib/python3.8/dist-packages/obspy/core/inventory/response.py:1895: UserWarning: More than one PolesZerosResponseStage encountered. Returning first one found.
warnings.warn(msg)

I would actually like to overload the message with trace info such as station name.

Thank you

Maybe the answer here is working for you: https://stackoverflow.com/a/30368735

The problem is that I would like the code to be able to continue after the warning (and as it already does). I just need to overload the message with more info.

I see, then what about this one:

Yes, it worked! Thank you :slight_smile: