Metadata-Version: 2.1
Name: printf-log-formatter
Version: 0.1.0
Classifier: Development Status :: 4 - Beta
Classifier: Environment :: Console
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: BSD License
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3 :: Only
Classifier: Programming Language :: Python :: 3.7
Classifier: Programming Language :: Python :: 3.8
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Rust
License-File: LICENSE
Summary: Convert logger f-strings and str.format syntax to printf-style strings
Keywords: linter,formatter,logging,sentry
Author: Sondre Lillebø Gundersen <sondrelg@live.no>
Author-email: Sondre Lillebø Gundersen <sondrelg@live.no>
Requires-Python: >=3.7
Description-Content-Type: text/markdown; charset=UTF-8; variant=GFM
Project-URL: Repository, https://github.com/sondrelg/printf-log-formatter
Project-URL: Changelog, https://github.com/sondrelg/printf-log-formatter/releases

<img src="https://raw.githubusercontent.com/sondrelg/printf-log-formatter/main/logo.svg?token=GHSAT0AAAAAACAOR4AAQVLI3YMI4IZKDAYCZBS5KOA&sanitize=true" alt="logo" width="110" align="right">

# printf-log-formatter

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

In other words,



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

is changed to

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


## Motivation

[This article](https://blog.pilosus.org/posts/2020/01/24/python-f-strings-in-logging/) explains it well.

tl;dr: It fixes Sentry log integration issues.

## Installation

Install with pre-commit, using:

```yaml
- 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
```

