printf-log-formatter


Nameprintf-log-formatter JSON
Version 0.3.0 PyPI version JSON
download
home_pageNone
SummaryConvert logger f-strings and str.format syntax to printf-style strings
upload_time2023-04-23 20:11:40
maintainerNone
docs_urlNone
authorSondre Lillebø Gundersen <sondrelg@live.no>
requires_python>=3.7
licenseNone
keywords linter formatter logging sentry
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            <a href="https://github.com/sondrelg/printf-log-formatter"><img src="https://raw.githubusercontent.com/sondrelg/printf-log-formatter/main/logo.svg?token=GHSAT0AAAAAACAOR4AAQVLI3YMI4IZKDAYCZBS5KOA&sanitize=true" alt="logo" width="110" align="right"></a>

# printf-log-formatter

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

In other words, this syntax

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

Why would we want to do this? [This article](https://blog.pilosus.org/posts/2020/01/24/python-f-strings-in-logging/) explains it pretty well.

Mainly it's useful for Python projects using [Sentry](https://sentry.io)'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:

```shell
pip install printf-log-formatter
```

then set the pre-commit hook up using:

```yaml
- repo: local
  hooks:
  - id: printf-log-formatter
    name: printf-log-formatter
    entry: printf-log-formatter
    language: system
    types: [ python ]
    args:
      - --log-level=error
```


### Rust hook

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

```yaml
- repo: https://github.com/sondrelg/printf-log-formatter
  rev: ''
  hooks:
    - id: printf-log-formatter
      args:
        - --log-level=error
```

## I just want to downgrade loggers once

The Rust binary or Python package can also be run directly, like this:

```shell
printf-log-formatter $(find . -name "*.py") --log-level error
```


            

Raw data

            {
    "_id": null,
    "home_page": null,
    "name": "printf-log-formatter",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.7",
    "maintainer_email": null,
    "keywords": "linter,formatter,logging,sentry",
    "author": "Sondre Lilleb\u00f8 Gundersen <sondrelg@live.no>",
    "author_email": "Sondre Lilleb\u00f8 Gundersen <sondrelg@live.no>",
    "download_url": null,
    "platform": null,
    "description": "<a href=\"https://github.com/sondrelg/printf-log-formatter\"><img src=\"https://raw.githubusercontent.com/sondrelg/printf-log-formatter/main/logo.svg?token=GHSAT0AAAAAACAOR4AAQVLI3YMI4IZKDAYCZBS5KOA&sanitize=true\" alt=\"logo\" width=\"110\" align=\"right\"></a>\n\n# printf-log-formatter\n\nAutomatically convert f-strings and `str.format()` syntax to printf-style strings.\n\nIn other words, this syntax\n\n```python\nlogger.error(f\"{1}\")\nlogger.error(\"{}\".format(1))\nlogger.error(\"{foo}\".format(foo=1))\n```\n\nis changed to\n\n```python\nlogger.error(\"%s\", 1)\nlogger.error(\"%s\", 1)\nlogger.error(\"%s\", 1)\n```\n\n\n## Motivation\n\nWhy would we want to do this? [This article](https://blog.pilosus.org/posts/2020/01/24/python-f-strings-in-logging/) explains it pretty well.\n\nMainly it's useful for Python projects using [Sentry](https://sentry.io)'s log integration.\n\n## Installation\n\nYou have two options for running this pre-commit hook:\n\n\n### Python hook\n\nIf you would like to install this using Python, run:\n\n```shell\npip install printf-log-formatter\n```\n\nthen set the pre-commit hook up using:\n\n```yaml\n- repo: local\n  hooks:\n  - id: printf-log-formatter\n    name: printf-log-formatter\n    entry: printf-log-formatter\n    language: system\n    types: [ python ]\n    args:\n      - --log-level=error\n```\n\n\n### Rust hook\n\nIf you're happy to compile the Rust version, you can use:\n\n```yaml\n- repo: https://github.com/sondrelg/printf-log-formatter\n  rev: ''\n  hooks:\n    - id: printf-log-formatter\n      args:\n        - --log-level=error\n```\n\n## I just want to downgrade loggers once\n\nThe Rust binary or Python package can also be run directly, like this:\n\n```shell\nprintf-log-formatter $(find . -name \"*.py\") --log-level error\n```\n\n",
    "bugtrack_url": null,
    "license": null,
    "summary": "Convert logger f-strings and str.format syntax to printf-style strings",
    "version": "0.3.0",
    "split_keywords": [
        "linter",
        "formatter",
        "logging",
        "sentry"
    ],
    "urls": [
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "e7c989e0cf694ced1721b81a50f7b9265fa7da3ce369833e4065cd2b75bbf22f",
                "md5": "d7a73d04030473d37fa2db8f939de306",
                "sha256": "a41bfba0d49dc16675ac9c180c3380903622a4f48d6a537c72394054ed513a35"
            },
            "downloads": -1,
            "filename": "printf_log_formatter-0.3.0-py3-none-macosx_10_7_x86_64.whl",
            "has_sig": false,
            "md5_digest": "d7a73d04030473d37fa2db8f939de306",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.7",
            "size": 1715476,
            "upload_time": "2023-04-23T20:11:40",
            "upload_time_iso_8601": "2023-04-23T20:11:40.536260Z",
            "url": "https://files.pythonhosted.org/packages/e7/c9/89e0cf694ced1721b81a50f7b9265fa7da3ce369833e4065cd2b75bbf22f/printf_log_formatter-0.3.0-py3-none-macosx_10_7_x86_64.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "a6a76e4449dffad3d095678c9badf1c487d1bc0ea7bba15ea6058f25f7c550a6",
                "md5": "a89655d4623d1eba9b169e5a828a32cf",
                "sha256": "c6bb875f2e7ede7467ee59a8f73125cb6361d9b599b8bcf8f9e1f2ca487519ae"
            },
            "downloads": -1,
            "filename": "printf_log_formatter-0.3.0-py3-none-macosx_11_0_arm64.whl",
            "has_sig": false,
            "md5_digest": "a89655d4623d1eba9b169e5a828a32cf",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.7",
            "size": 1646154,
            "upload_time": "2023-04-23T20:11:42",
            "upload_time_iso_8601": "2023-04-23T20:11:42.110260Z",
            "url": "https://files.pythonhosted.org/packages/a6/a7/6e4449dffad3d095678c9badf1c487d1bc0ea7bba15ea6058f25f7c550a6/printf_log_formatter-0.3.0-py3-none-macosx_11_0_arm64.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "7d12acae1118f9481758d6981808b0183f92ac6228b63cee315eb6c99a390d3f",
                "md5": "f31ec873549162db6e845ae13e210157",
                "sha256": "300af2cdeafde7e4f0b631d41e82ceb7322a290b8e04c4e4bb35f8334ae9c7e5"
            },
            "downloads": -1,
            "filename": "printf_log_formatter-0.3.0-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.whl",
            "has_sig": false,
            "md5_digest": "f31ec873549162db6e845ae13e210157",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.7",
            "size": 2720656,
            "upload_time": "2023-04-23T20:11:43",
            "upload_time_iso_8601": "2023-04-23T20:11:43.672537Z",
            "url": "https://files.pythonhosted.org/packages/7d/12/acae1118f9481758d6981808b0183f92ac6228b63cee315eb6c99a390d3f/printf_log_formatter-0.3.0-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "d784ada8ce24e04ca4142c5ac4726d9ce284df4cf2ffdc505d6716b3ef950d6d",
                "md5": "cf1159b88e70b658110307d34fb65d7f",
                "sha256": "b51bfb73707f47b0dddc215a4660d088be918a250f5040683b724d2a2a9ad4d6"
            },
            "downloads": -1,
            "filename": "printf_log_formatter-0.3.0-py3-none-manylinux_2_17_armv7l.manylinux2014_armv7l.whl",
            "has_sig": false,
            "md5_digest": "cf1159b88e70b658110307d34fb65d7f",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.7",
            "size": 2679801,
            "upload_time": "2023-04-23T20:11:46",
            "upload_time_iso_8601": "2023-04-23T20:11:46.368743Z",
            "url": "https://files.pythonhosted.org/packages/d7/84/ada8ce24e04ca4142c5ac4726d9ce284df4cf2ffdc505d6716b3ef950d6d/printf_log_formatter-0.3.0-py3-none-manylinux_2_17_armv7l.manylinux2014_armv7l.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "b2bc62e5b8e4a8e15b3fcc0a245346f090a0e0a855aaf191dc6c2a62106d1237",
                "md5": "03572eca28f4799589b6a6dd2b0946f6",
                "sha256": "b7099fa053a3eae2e9594f18712458b90d8008bc5f942f67bb18f9bc351001cd"
            },
            "downloads": -1,
            "filename": "printf_log_formatter-0.3.0-py3-none-manylinux_2_17_i686.manylinux2014_i686.whl",
            "has_sig": false,
            "md5_digest": "03572eca28f4799589b6a6dd2b0946f6",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.7",
            "size": 2866566,
            "upload_time": "2023-04-23T20:11:49",
            "upload_time_iso_8601": "2023-04-23T20:11:49.195021Z",
            "url": "https://files.pythonhosted.org/packages/b2/bc/62e5b8e4a8e15b3fcc0a245346f090a0e0a855aaf191dc6c2a62106d1237/printf_log_formatter-0.3.0-py3-none-manylinux_2_17_i686.manylinux2014_i686.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "88d544cfa70266d7ec5498976e9d9ec9765202cadbd1ff798b391bd1157975c4",
                "md5": "7e7409b9f5ad403fdc6716cea4d1781f",
                "sha256": "d17c0e555ed68249071675f8a86310b251fb84711a1928bfef5d0d14ece2f410"
            },
            "downloads": -1,
            "filename": "printf_log_formatter-0.3.0-py3-none-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl",
            "has_sig": false,
            "md5_digest": "7e7409b9f5ad403fdc6716cea4d1781f",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.7",
            "size": 2960161,
            "upload_time": "2023-04-23T20:11:51",
            "upload_time_iso_8601": "2023-04-23T20:11:51.011450Z",
            "url": "https://files.pythonhosted.org/packages/88/d5/44cfa70266d7ec5498976e9d9ec9765202cadbd1ff798b391bd1157975c4/printf_log_formatter-0.3.0-py3-none-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "bf8e5bd8d4a1a5b209f4de07ad412a47bd7c2cd4fd70d3973657d9bcff6dec34",
                "md5": "c4eb7a38ed8b400bce4a25b3eb9ebaf6",
                "sha256": "af414b2e2d5b78504ace2d5b76b8aaae0afbc894314b56be170d8a052ba81388"
            },
            "downloads": -1,
            "filename": "printf_log_formatter-0.3.0-py3-none-manylinux_2_17_s390x.manylinux2014_s390x.whl",
            "has_sig": false,
            "md5_digest": "c4eb7a38ed8b400bce4a25b3eb9ebaf6",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.7",
            "size": 2866673,
            "upload_time": "2023-04-23T20:11:53",
            "upload_time_iso_8601": "2023-04-23T20:11:53.973273Z",
            "url": "https://files.pythonhosted.org/packages/bf/8e/5bd8d4a1a5b209f4de07ad412a47bd7c2cd4fd70d3973657d9bcff6dec34/printf_log_formatter-0.3.0-py3-none-manylinux_2_17_s390x.manylinux2014_s390x.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "96e15556a067332dbf256e31f93e9bf2c0cd85a3cff6ccf5b2c476bdb51a20df",
                "md5": "778d858852b8f6e2b93f21098d52fb56",
                "sha256": "97d675c90d84b87ecaa48d867b937876d46c66b0d480bf2bae373738fe8a3d17"
            },
            "downloads": -1,
            "filename": "printf_log_formatter-0.3.0-py3-none-manylinux_2_17_x86_64.manylinux2014_x86_64.whl",
            "has_sig": false,
            "md5_digest": "778d858852b8f6e2b93f21098d52fb56",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.7",
            "size": 2720419,
            "upload_time": "2023-04-23T20:11:55",
            "upload_time_iso_8601": "2023-04-23T20:11:55.595887Z",
            "url": "https://files.pythonhosted.org/packages/96/e1/5556a067332dbf256e31f93e9bf2c0cd85a3cff6ccf5b2c476bdb51a20df/printf_log_formatter-0.3.0-py3-none-manylinux_2_17_x86_64.manylinux2014_x86_64.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "ff7fde892947e6860caf2f9fb1185006722870ebddda2cfdefce4602cd9fa0e2",
                "md5": "1f778c0d42f0d9c9b44c3dad129539b6",
                "sha256": "d2fc29f8776121c1477100287c285d4798d310d0547f4573ad3eae23b66549cc"
            },
            "downloads": -1,
            "filename": "printf_log_formatter-0.3.0-py3-none-win32.whl",
            "has_sig": false,
            "md5_digest": "1f778c0d42f0d9c9b44c3dad129539b6",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.7",
            "size": 1454476,
            "upload_time": "2023-04-23T20:11:57",
            "upload_time_iso_8601": "2023-04-23T20:11:57.440575Z",
            "url": "https://files.pythonhosted.org/packages/ff/7f/de892947e6860caf2f9fb1185006722870ebddda2cfdefce4602cd9fa0e2/printf_log_formatter-0.3.0-py3-none-win32.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "f35f22d83a59f2aa7201179d73eacc26ab10846d1e47933d75480e123b1bcf83",
                "md5": "30c2cd274dd16e021c88230a767081a1",
                "sha256": "27c3f053166bfe74e490661e8fe47167b12b8ca4d3066ba13f1ab53d1c7c6788"
            },
            "downloads": -1,
            "filename": "printf_log_formatter-0.3.0-py3-none-win_amd64.whl",
            "has_sig": false,
            "md5_digest": "30c2cd274dd16e021c88230a767081a1",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.7",
            "size": 1585060,
            "upload_time": "2023-04-23T20:11:59",
            "upload_time_iso_8601": "2023-04-23T20:11:59.199754Z",
            "url": "https://files.pythonhosted.org/packages/f3/5f/22d83a59f2aa7201179d73eacc26ab10846d1e47933d75480e123b1bcf83/printf_log_formatter-0.3.0-py3-none-win_amd64.whl",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-04-23 20:11:40",
    "github": false,
    "gitlab": false,
    "bitbucket": false,
    "lcname": "printf-log-formatter"
}
        
Elapsed time: 0.05961s