Devpy is a set of tools to ease Python development, providing automatic logging
MIT License
Devpy is a set of tools to ease Python development.
::
pip install devpy
Devpy provides a quick dev setup for logging that you can replace later by a more robust solution:
.. code:: python
import devpy.develop as log
log.info('This is an info')
log.warning('This is a warning')
log.error('This is an error')
log.critical('This is a critical error')
log.info('Now let me crash the program. This stack trace is automatically in the log file:')
import codecs
codecs.open('/thisdoesnotexist')
This gives:
.. image:: screenshot.png
Setting up proper logging is tedious, so you may want to do it later, but you wish you could get basic logging right away:
.. code:: python
import devpy
# Get a logger that automatically logs to console and a rotating file
# The rotating file is setup in the temp directory of your system, in
# a subdir named after your script name.
# Logs are colored in the console according to their level.
# The file path is printed at the beginning of the program.
log = devpy.autolog() # log is a regular stdlib logger object
# start logging:
log.info('Yes')
Once you have time to setup logging seriously, you can just replace the autolog with a regular custom Python logger, and all your logs will still work.
Setting the environment variable DEVPY_LOG_LEVEL to an integer or a level name (debug, info, error, warning, critical...) will set the autolog log to it.
Setting the environment variable DEVPY_COLOR_LOG to 0 disables log highlighting.
autolog parameters:
Format the stack trace so that:
Just do:
.. code:: python
import devpy
devpy.color_traceback()
Two ways:
.. code:: python
import devpy
log = devpy.dev_mode() # can set color_traceback=True, autolog=True
# or just
# import devpy.develop as log
# for a one liner to activate it all