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 Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distributions

printf_log_formatter-0.2.0-py3-none-win_amd64.whl (1.6 MB view hashes)

Uploaded Python 3 Windows x86-64

printf_log_formatter-0.2.0-py3-none-win32.whl (1.5 MB view hashes)

Uploaded Python 3 Windows x86

printf_log_formatter-0.2.0-py3-none-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (2.7 MB view hashes)

Uploaded Python 3 manylinux: glibc 2.17+ x86-64

printf_log_formatter-0.2.0-py3-none-manylinux_2_17_s390x.manylinux2014_s390x.whl (2.9 MB view hashes)

Uploaded Python 3 manylinux: glibc 2.17+ s390x

printf_log_formatter-0.2.0-py3-none-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl (3.0 MB view hashes)

Uploaded Python 3 manylinux: glibc 2.17+ ppc64le

printf_log_formatter-0.2.0-py3-none-manylinux_2_17_i686.manylinux2014_i686.whl (2.9 MB view hashes)

Uploaded Python 3 manylinux: glibc 2.17+ i686

printf_log_formatter-0.2.0-py3-none-manylinux_2_17_armv7l.manylinux2014_armv7l.whl (2.7 MB view hashes)

Uploaded Python 3 manylinux: glibc 2.17+ ARMv7l

printf_log_formatter-0.2.0-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (2.7 MB view hashes)

Uploaded Python 3 manylinux: glibc 2.17+ ARM64

printf_log_formatter-0.2.0-py3-none-macosx_11_0_arm64.whl (1.6 MB view hashes)

Uploaded Python 3 macOS 11.0+ ARM64

printf_log_formatter-0.2.0-py3-none-macosx_10_7_x86_64.whl (1.7 MB view hashes)

Uploaded Python 3 macOS 10.7+ 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