Convert logger f-strings and str.format syntax to printf-style strings
Project description
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
Built Distribution
File details
Details for the file printf_log_formatter-0.1.0.tar.gz
.
File metadata
- Download URL: printf_log_formatter-0.1.0.tar.gz
- Upload date:
- Size: 26.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: maturin/0.14.17
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 95d9275aedc8dfbfde6e65aebb7d38bf6bcc0cc4d85ed20b6ce2ff01bd463e6d |
|
MD5 | c8d5aab2a7b9a53483c6706eddd2c0b5 |
|
BLAKE2b-256 | f265fe6a28f40954e37b43a06c8e92237ee9ca3c63c22f5975364b67699f3842 |
File details
Details for the file printf_log_formatter-0.1.0-cp310-cp310-manylinux_2_34_x86_64.whl
.
File metadata
- Download URL: printf_log_formatter-0.1.0-cp310-cp310-manylinux_2_34_x86_64.whl
- Upload date:
- Size: 2.7 MB
- Tags: CPython 3.10, manylinux: glibc 2.34+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.10.6
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 386db7cf1b8851910fe64a3e938144abc9304a633bdf210049f0f7e6ffc181aa |
|
MD5 | a05d10a552084d4df1358d351c776f94 |
|
BLAKE2b-256 | f7079e80577fc7b02f67310e10183dff4fae08d1a2f1780e9dbe5fb845997995 |