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.2-py3-none-win_amd64.whl (1.6 MB view details)

Uploaded Python 3 Windows x86-64

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

Uploaded Python 3 Windows x86

printf_log_formatter-0.2.2-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.2-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.2-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.2-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.2-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.2-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.2-py3-none-macosx_11_0_arm64.whl (1.6 MB view details)

Uploaded Python 3 macOS 11.0+ ARM64

printf_log_formatter-0.2.2-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.2-py3-none-win_amd64.whl.

File metadata

File hashes

Hashes for printf_log_formatter-0.2.2-py3-none-win_amd64.whl
Algorithm Hash digest
SHA256 63bc2823472ee2c619fe815a8a1d6ab2f16b47fb5762cc5085b238391ccfa134
MD5 194d8a0f080e49ae685a09bbf101e15d
BLAKE2b-256 71a7a4ff1c9b475a0ba3c6c4798e61494f8711ea66bffaf73d29842ece1cd89c

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for printf_log_formatter-0.2.2-py3-none-win32.whl
Algorithm Hash digest
SHA256 0b35070b8274625f5ed3e43eaeba887396d416a999ee7ffeae0e506f24753bd9
MD5 6434ad867c2a535560a4b5077bc4d6db
BLAKE2b-256 c452c66d716c7c9693dcd1cadfb438f2f88c26c78c40f4f5a0884fedb752c58e

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for printf_log_formatter-0.2.2-py3-none-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 326a06a6a941da510591456a1b5b14e4d9146bb7f4177d4c4491d1eaccf971b0
MD5 18bc5be3b35ffee50923b7ed77d3fae8
BLAKE2b-256 da77cd69d267f3e4a50a0c99976cd6824cdef2b4edea2de3959e30568c629e3c

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for printf_log_formatter-0.2.2-py3-none-manylinux_2_17_s390x.manylinux2014_s390x.whl
Algorithm Hash digest
SHA256 1abbd8ce8e73ab0c3b4e04ac6e35bdc4c75dbcc966f40988734ea6fbefbc9b32
MD5 83727197de11a2e9e6d6b3c07be2885a
BLAKE2b-256 e8abc805d6ff76ed6e9a1a2e5100a56ef7755d7bf2ce05d8763e276ab52bf569

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for printf_log_formatter-0.2.2-py3-none-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl
Algorithm Hash digest
SHA256 8de026f24d23883e793180ceb6d1a7688a6cead707c50c351bab0e3842ca376d
MD5 8a6cbbedf9fe01569095ffc56ad33448
BLAKE2b-256 cacea3deecb11717f91ae5f831ef75f19240dd49156a07d0fd644e6bf74450aa

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for printf_log_formatter-0.2.2-py3-none-manylinux_2_17_i686.manylinux2014_i686.whl
Algorithm Hash digest
SHA256 520fda659dee0957570c5b7dbdd1c5540394e05a85d97af81b4d169ace0755ac
MD5 053b6094e04be6f764838d166d3ef4d4
BLAKE2b-256 1c38ca3c81c71ae7e63d0df90e91f0702b4940b33ce4b7d789b65f7a8ec8924c

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for printf_log_formatter-0.2.2-py3-none-manylinux_2_17_armv7l.manylinux2014_armv7l.whl
Algorithm Hash digest
SHA256 746c72241e5f57ff5e04e85ddef2a59fc9b5bde472b86876593bf4110d83d42e
MD5 29538c8ff488a5c544390e2e5cbd22ed
BLAKE2b-256 14fe3cc7e56b1a2325e253433c44298797ccc397db0fac03c7fb6cff191d339a

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for printf_log_formatter-0.2.2-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 b9f8b0c98b794f992eaca803a4720afb93d9664c60e8cc29e85cea30362b593d
MD5 49a34d022fbfc44aa3a9037cd1a258d7
BLAKE2b-256 82922c35819ed5d2334f026171b07db4e4795ec8cacaa55744b8320f601fbf9a

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for printf_log_formatter-0.2.2-py3-none-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 8e2fb493c8d74643b2b94d57f40343ddf6fd6394ef74cb3126da14a8ba187415
MD5 3a00034cb29e0f0a3fa934a91335e04c
BLAKE2b-256 d370a52022447f130923808749495483e495f799fc80729f497503428f3cfe78

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for printf_log_formatter-0.2.2-py3-none-macosx_10_7_x86_64.whl
Algorithm Hash digest
SHA256 ca6cad69962baad60f8ffdff404ab72126f1955b506d6e675abf6c7c7609446f
MD5 5d2f59af18b146c98badb0a8047931fd
BLAKE2b-256 89e19e6e49562dc2df6455da135949a6016a87bdb9517303a47fedfa58c12858

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