How can I set error reporting and warning outputs in Python like in PHP error_reporting(E_LEVEL)?
How can I set error reporting and warning outputs in Python like in PHP
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
A vaguely related option might be the setting of level in the
loggingmodule of the Python standard library, and I quote from Python’s docs:That
level=determines which logging messages are emitted and which ones are filtered. However this only applies to errors (and other messages) emitted throughloggingmodule functions, not to (e.g) tracebacks resulting from exceptions; if you want to control the latter (what kinds of message come out when the process dies by propagating an exception), you can build something based on sys.excepthook, but your degrees of freedom will still be somewhat limited (in particular, after the reporting — abundant or scarce as it may be — the process will exit if an exception has propagated to that point).