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, this syntax

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

Why would we want to do this? This article explains it pretty well.

Mainly it's useful for Python projects using Sentry's log integration.

Installation

You have two options for running this pre-commit hook:

Python hook

If you would like to install this using Python, run:

pip install printf-log-formatter

then set the pre-commit hook up using:

- repo: local
  hooks:
  - id: printf-log-formatter
    name: printf-log-formatter
    entry: printf-log-formatter
    language: system
    types: [ python ]
    args:
      - --log-level=error
      - --quotes=single  # or double

Rust hook

If you're happy to compile the Rust version, you can use:

- repo: https://github.com/sondrelg/printf-log-formatter
  rev: v0.2.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.1-py3-none-win_amd64.whl (1.6 MB view details)

Uploaded Python 3 Windows x86-64

printf_log_formatter-0.2.1-py3-none-win32.whl (1.5 MB view details)

Uploaded Python 3 Windows x86

printf_log_formatter-0.2.1-py3-none-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (2.7 MB view details)

Uploaded Python 3 manylinux: glibc 2.17+ x86-64

printf_log_formatter-0.2.1-py3-none-manylinux_2_17_s390x.manylinux2014_s390x.whl (2.9 MB view details)

Uploaded Python 3 manylinux: glibc 2.17+ s390x

printf_log_formatter-0.2.1-py3-none-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl (3.0 MB view details)

Uploaded Python 3 manylinux: glibc 2.17+ ppc64le

printf_log_formatter-0.2.1-py3-none-manylinux_2_17_i686.manylinux2014_i686.whl (2.9 MB view details)

Uploaded Python 3 manylinux: glibc 2.17+ i686

printf_log_formatter-0.2.1-py3-none-manylinux_2_17_armv7l.manylinux2014_armv7l.whl (2.7 MB view details)

Uploaded Python 3 manylinux: glibc 2.17+ ARMv7l

printf_log_formatter-0.2.1-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (2.7 MB view details)

Uploaded Python 3 manylinux: glibc 2.17+ ARM64

printf_log_formatter-0.2.1-py3-none-macosx_11_0_arm64.whl (1.6 MB view details)

Uploaded Python 3 macOS 11.0+ ARM64

printf_log_formatter-0.2.1-py3-none-macosx_10_7_x86_64.whl (1.7 MB view details)

Uploaded Python 3 macOS 10.7+ x86-64

File details

Details for the file printf_log_formatter-0.2.1-py3-none-win_amd64.whl.

File metadata

File hashes

Hashes for printf_log_formatter-0.2.1-py3-none-win_amd64.whl
Algorithm Hash digest
SHA256 3a52ca06162868d339e509f954e732324f711f58b9851ca0d749ba93420361d0
MD5 d19ad3af51ef94ea48c6df002b97a541
BLAKE2b-256 cc538028a0978ecb8768cb1c61f16f0af0ac20f6ad4fdd6a63a0fa79f9aa6163

See more details on using hashes here.

File details

Details for the file printf_log_formatter-0.2.1-py3-none-win32.whl.

File metadata

File hashes

Hashes for printf_log_formatter-0.2.1-py3-none-win32.whl
Algorithm Hash digest
SHA256 fb315880a0bc9f9b667e5e48c2a0655195aa6e6f717db12bf942a6688e938477
MD5 a4237f2be89236b3230548dbb5e011b5
BLAKE2b-256 47441d7202becccde4906a99e312353d1c654f483385534807ae72e86c367c55

See more details on using hashes here.

File details

Details for the file printf_log_formatter-0.2.1-py3-none-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for printf_log_formatter-0.2.1-py3-none-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 f3d52f2d0a7607541a87ddc8f541ae4c00f6180d6d68accf77d7921e843e90cc
MD5 c7d20775bed30628b91a398265962196
BLAKE2b-256 1d0aca09b52edd1b09bd7d92c5d25681c668da0d472dde00d0ca75597d33a6ad

See more details on using hashes here.

File details

Details for the file printf_log_formatter-0.2.1-py3-none-manylinux_2_17_s390x.manylinux2014_s390x.whl.

File metadata

File hashes

Hashes for printf_log_formatter-0.2.1-py3-none-manylinux_2_17_s390x.manylinux2014_s390x.whl
Algorithm Hash digest
SHA256 fb7484fd39f8652a02e0a6cb36764a25fa54982e6480d1276c94987685cb0d6b
MD5 608fe97691068d54d5d8af32a1f7d17b
BLAKE2b-256 142ab5e3277e68931e3bd95dc05c39cc5b4e20aeac1864d14e32e03e2d3a8565

See more details on using hashes here.

File details

Details for the file printf_log_formatter-0.2.1-py3-none-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl.

File metadata

File hashes

Hashes for printf_log_formatter-0.2.1-py3-none-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl
Algorithm Hash digest
SHA256 06cd82e146a6bfc3c5d16d28a59db2717956393bdfcdc4f941526debdd3dc97f
MD5 bd31d9a99d67d88cfe2953a41a961c0b
BLAKE2b-256 e8a21653aa42d627d4860b2ee8e97b6bc2b84eca527e849c0656cf9d565e89fd

See more details on using hashes here.

File details

Details for the file printf_log_formatter-0.2.1-py3-none-manylinux_2_17_i686.manylinux2014_i686.whl.

File metadata

File hashes

Hashes for printf_log_formatter-0.2.1-py3-none-manylinux_2_17_i686.manylinux2014_i686.whl
Algorithm Hash digest
SHA256 31e5a848031649bda2d8a2c067952a93d763fcc477296ea1958430cb303a5d34
MD5 34a40d0466ef52572520b49c60d27011
BLAKE2b-256 3984700ff19ed7c1e851c9d719a897b7349bd44ee4bd7796ee7f3d8f76e421b2

See more details on using hashes here.

File details

Details for the file printf_log_formatter-0.2.1-py3-none-manylinux_2_17_armv7l.manylinux2014_armv7l.whl.

File metadata

File hashes

Hashes for printf_log_formatter-0.2.1-py3-none-manylinux_2_17_armv7l.manylinux2014_armv7l.whl
Algorithm Hash digest
SHA256 24ef27fdffcddb77264af640512ddea456f7e4e99668fcfc3fad3907a088997c
MD5 56e450e203b3dd4bdbfd9b8d2472adf0
BLAKE2b-256 6442a8d4991ac6213e6fcad50825a921616d5a9310567be03f45b9fb1e614db7

See more details on using hashes here.

File details

Details for the file printf_log_formatter-0.2.1-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.

File metadata

File hashes

Hashes for printf_log_formatter-0.2.1-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 a02bf5b260a7b058b339f478ca6c0882854f116943cf77ce2f83d3f196d41ccf
MD5 e597d323e5bdf2ece139554f94a08469
BLAKE2b-256 0ce1ced9dbd109fa123cb2b9431c1c6e409d7aaba91681ca6c69e08056298e30

See more details on using hashes here.

File details

Details for the file printf_log_formatter-0.2.1-py3-none-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for printf_log_formatter-0.2.1-py3-none-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 42705bcce5a61145814eb863ade86204ca1700cc38ceb2e9e5bd4fa054d10153
MD5 ba7a3883c99ea3366c50277d1c1dc7eb
BLAKE2b-256 ba84501e451f743b104a5f797f84231ec78da9226c0253a9739822d5c7f542eb

See more details on using hashes here.

File details

Details for the file printf_log_formatter-0.2.1-py3-none-macosx_10_7_x86_64.whl.

File metadata

File hashes

Hashes for printf_log_formatter-0.2.1-py3-none-macosx_10_7_x86_64.whl
Algorithm Hash digest
SHA256 520db5583aa41c6009d471bac6f1d256db818956fc96555ee60e0443ec0bb09b
MD5 b2cf6933cb1dc84e8fcf84b17e559ff3
BLAKE2b-256 b7749633a4709a622d77a8aa6f788efce3f1c2f0b04dd94b168596f65da0b0e0

See more details on using hashes here.

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