Skip to main content

Convert logger f-strings and str.format syntax to printf-style strings

Project description

logo

printf-log-formatter

Automatically convert f-strings and str.format() syntax to printf style strings.

In other words,

logger.error(f"{1}")
logger.error("{}".format(1))
logger.error("{foo}".format(foo=1))

is changed to

logger.error("%s", 1)
logger.error("%s", 1)
logger.error("%s", 1)

Motivation

This article explains it well.

tl;dr: It fixes Sentry log integration issues.

Installation

Install with pre-commit, using:

- repo: https://github.com/sondrelg/printf-log-formatter
  rev: v0.1.0
  hooks:
    - id: printf-log-formatter
      args:
        - --log-level=error
        - --quotes=single  # or double

Project details


Download files

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

Source Distribution

printf_log_formatter-0.1.0.tar.gz (26.7 kB view hashes)

Uploaded Source

Built Distribution

printf_log_formatter-0.1.0-cp310-cp310-manylinux_2_34_x86_64.whl (2.7 MB view hashes)

Uploaded CPython 3.10 manylinux: glibc 2.34+ x86-64

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page