A bowerbird is known to like colours in its courtship behaviours. I do to, in my logging.
pip install bowerbird
LOGGING = { ... 'formatters': { 'bowerbird_formatter': { '()': bowerbird.formatters.PygmentsFormatter, }, ... }
Then, in code, use with optional extra params:
data
: any python object, can be nested, will be pygentized and pretty printedfree
: Any text, will also by pygmentizedsql
: SQL string, will be formatted and pygmentized
free = "db_counts:\nauth_user from 0 to 10" logger.debug( 'I got this data', extra={'data': some_obj.__dict__, 'free': free} )
- Add DjangoColorSQLFormatter - ready, but not tested
- Add SQLAlchemyColorSQLFormatter - ready but not tested
- Have a look at pip.utils.logging.ColorizedStreamHandler, does it overlap?
- Add Python3 support
- Add more examples to configuration
MIT