Skip to main content

A collection of stdlib logging.Formatter classes using Pygments

Project description

Bowerbird - A collection of stdlib logging.Formatter classes using Pygments

A bowerbird is known to like colours in its courtship behaviours. I do to, in my logging.

Install

pip install bowerbird

Use

dictConfig:

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 printed
  • free: Any text, will also by pygmentized
  • sql: 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}
)

TODO / Research

  • 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

License

MIT

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for bowerbird, version 0.4.0
Filename, size File type Python version Upload date Hashes
Filename, size bowerbird-0.4.0.tar.gz (2.6 kB) File type Source Python version None Upload date Hashes View hashes

Supported by

Elastic Elastic Search Pingdom Pingdom Monitoring Google Google BigQuery Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN DigiCert DigiCert EV certificate StatusPage StatusPage Status page