Logging in Python Like a Pro

This page summarizes the projects mentioned and recommended in the original post on news.ycombinator.com

Our great sponsors
  • InfluxDB - Power Real-Time Data Analytics at Scale
  • WorkOS - The modern identity platform for B2B SaaS
  • SaaSHub - Software Alternatives and Reviews
  • python-logging-discord-handler

    Redirect your Python log output to Discord

  • A very good post on creating good log contexts.

    For powerful log channeling and notifications to Telegram, Slack, etc. there is this Python package:

    https://pypi.org/project/notifiers/

    I also created a logging handler for Discord, where one can get notifications on errors to a private channel:

    https://github.com/tradingstrategy-ai/python-logging-discord...

  • A very good post on creating good log contexts.

    For powerful log channeling and notifications to Telegram, Slack, etc. there is this Python package:

    https://pypi.org/project/notifiers/

    I also created a logging handler for Discord, where one can get notifications on errors to a private channel:

    https://github.com/tradingstrategy-ai/python-logging-discord...

  • InfluxDB

    Power Real-Time Data Analytics at Scale. Get real-time insights from all types of time series data with InfluxDB. Ingest, query, and analyze billions of data points in real-time with unbounded cardinality.

    InfluxDB logo
  • awslogs

    AWS CloudWatch logs for Humans™

  • Using the official CLI (aws logs get-log-events) or https://github.com/jorgebastida/awslogs is pretty close to SSH-ing and grepping.

  • vector

    A high-performance observability data pipeline.

  • Honestly, I like to keep the logger as decoupled and minimalist as possible. There’s https://vector.dev which can basically ship your logs from source A to destination B. Separation of concerns makes things much more easier.

  • logma

    structlog defaults for machines not for humans

  • You always need some boilerplate to get structlog working. I always use this (author) to have the needed defaults https://github.com/peakiq/logma.

  • python-logfmter

    Using the stdlib logging module and without changing a single logging call, logfmter supports global (first and third party) logfmt structured logging.

  • https://github.com/jteppinette/python-logfmter

    I made this library to make global structured logging in Python super easy.

  • django-guid

    Inject an ID into every log message from a Django request. ASGI compatible, integrates with Sentry, and works with Celery

  • WorkOS

    The modern identity platform for B2B SaaS. The APIs are flexible and easy-to-use, supporting authentication, user identity, and complex enterprise features like SSO and SCIM provisioning.

    WorkOS logo
  • asgi-correlation-id

    Request ID propagation for ASGI apps

  • Loguru

    Python logging made (stupidly) simple

  • You should try the loguru library. I was able to roll a rolling-upload-to-s3 adapter in under an hour. Switching to json logs is one bool flag away. Plus it's gorgeous

    https://github.com/Delgan/loguru

    Also iirc s3's "file-like interface" does not actually obey the file protocol, which is obnoxious.

  • pygogo

    A Python logging library with superpowers

  • I'd just like to plug my lib, pygogo (https://github.com/reubano/pygogo). Here's a structured log example taken from the docs.

      import pygogo as gogo

  • bracelogger

    A Python library that enables using the brace-style string formatting in log messages

  • As there are real advantages to providing a template and object args separately, this is a bit of a shame since it pushes people to use pre-formatted strings without any args instead.

    I fixed this for myself by writing bracelogger[0]. If this is a pain point for you too, you might find it useful.

    [0]: https://github.com/pR0Ps/bracelogger

NOTE: The number of mentions on this list indicates mentions on common posts plus user suggested alternatives. Hence, a higher number means a more popular project.

Suggest a related project

Related posts