Python set error reporting level like in PHP
Question: How can I set error reporting and warning outputs in Python like in PHP
`error_reporting(E_LEVEL)`?


Answer: A vaguely related option might be the setting of level in the
[`logging`](http://docs.python.org/library/logging.html) module of the Python
standard library, and I quote from Python's docs:

    
    
    import logging
    LOG_FILENAME = 'example.log'
    logging.basicConfig(filename=LOG_FILENAME,level=logging.DEBUG)
    
    logging.debug('This message should go to the log file')
    

That `level=` determines which logging messages are emitted and which ones are
filtered. However this only applies to errors (and other messages) emitted
through `logging` module 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](http://docs.python.org/library/sys.html#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).

