subprocess-logger


Namesubprocess-logger JSON
Version 0.3.0 PyPI version JSON
download
home_pagehttps://github.com/Vi-Nk/subprocess-logger/
SummaryConsolidated handler for subprocess logging
upload_time2025-09-12 14:28:26
maintainerNone
docs_urlNone
authorVi-Nk
requires_python>=3.7
licenseMIT License Copyright (c) 2025 Vi-Nk Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
keywords subprocess logging loggers
VCS
bugtrack_url
requirements pytest wheel setuptools
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # subprocess-logger

Consolidated handler for subprocess logging in Python.

## Overview

`subprocess-logger` provides a unified way to capture and forward output from Python subprocesses to the standard logging system. It is useful for applications that spawn subprocesses and want to collect their stdout and stderr streams in a thread-safe, structured manner.

## Features

- Collects stdout and stderr from subprocesses and logs them using Python's `logging` module.
- Allows log level customization at global and per process level for stdout and stderr.
- Thread-safe collection and dispatching of logs.
- Easy integration with existing logging configurations.

## Installation

```sh
pip install subprocess-logger
```

## Usage

Below is a basic usage example:

```python
import logging
import subprocess
from subprocess_logger import install

# Configure root logger to print to console
logging.basicConfig(level=logging.DEBUG, format="%(levelname)s %(message)s")

# Create a collector instance
collector = install(stdout_level=logging.INFO, stderr_level=logging.WARNING)

# Start a subprocess that prints to stdout and stderr
proc = subprocess.Popen(
    ["python", "-c", "import sys; print('hello from stdout'); sys.stderr.write('hello from stderr\\n')"],
    stdout=subprocess.PIPE,
    stderr=subprocess.PIPE
)

# Attach the subprocess to the collector
collector.attach(proc, logger_name="demo_subprocess")

# Wait for the subprocess to finish
proc.wait()

# Stop the collector (waits for all logs to be processed)
collector.stop()
```

## Testing

To run unit tests, use the following command:

```sh
pytest
```

Or, if you have `tox` installed:

```sh
tox
```

## License

This project is licensed under the MIT License.

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/Vi-Nk/subprocess-logger/",
    "name": "subprocess-logger",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.7",
    "maintainer_email": null,
    "keywords": "subprocess, logging, loggers",
    "author": "Vi-Nk",
    "author_email": null,
    "download_url": "https://files.pythonhosted.org/packages/b5/57/084e1afd45d16f9c5ae7de3cd52e8b79dacdb45f10155020df217c35db3d/subprocess_logger-0.3.0.tar.gz",
    "platform": null,
    "description": "# subprocess-logger\r\n\r\nConsolidated handler for subprocess logging in Python.\r\n\r\n## Overview\r\n\r\n`subprocess-logger` provides a unified way to capture and forward output from Python subprocesses to the standard logging system. It is useful for applications that spawn subprocesses and want to collect their stdout and stderr streams in a thread-safe, structured manner.\r\n\r\n## Features\r\n\r\n- Collects stdout and stderr from subprocesses and logs them using Python's `logging` module.\r\n- Allows log level customization at global and per process level for stdout and stderr.\r\n- Thread-safe collection and dispatching of logs.\r\n- Easy integration with existing logging configurations.\r\n\r\n## Installation\r\n\r\n```sh\r\npip install subprocess-logger\r\n```\r\n\r\n## Usage\r\n\r\nBelow is a basic usage example:\r\n\r\n```python\r\nimport logging\r\nimport subprocess\r\nfrom subprocess_logger import install\r\n\r\n# Configure root logger to print to console\r\nlogging.basicConfig(level=logging.DEBUG, format=\"%(levelname)s %(message)s\")\r\n\r\n# Create a collector instance\r\ncollector = install(stdout_level=logging.INFO, stderr_level=logging.WARNING)\r\n\r\n# Start a subprocess that prints to stdout and stderr\r\nproc = subprocess.Popen(\r\n    [\"python\", \"-c\", \"import sys; print('hello from stdout'); sys.stderr.write('hello from stderr\\\\n')\"],\r\n    stdout=subprocess.PIPE,\r\n    stderr=subprocess.PIPE\r\n)\r\n\r\n# Attach the subprocess to the collector\r\ncollector.attach(proc, logger_name=\"demo_subprocess\")\r\n\r\n# Wait for the subprocess to finish\r\nproc.wait()\r\n\r\n# Stop the collector (waits for all logs to be processed)\r\ncollector.stop()\r\n```\r\n\r\n## Testing\r\n\r\nTo run unit tests, use the following command:\r\n\r\n```sh\r\npytest\r\n```\r\n\r\nOr, if you have `tox` installed:\r\n\r\n```sh\r\ntox\r\n```\r\n\r\n## License\r\n\r\nThis project is licensed under the MIT License.\r\n",
    "bugtrack_url": null,
    "license": "MIT License\r\n        \r\n        Copyright (c) 2025 Vi-Nk\r\n        \r\n        Permission is hereby granted, free of charge, to any person obtaining a copy\r\n        of this software and associated documentation files (the \"Software\"), to deal\r\n        in the Software without restriction, including without limitation the rights\r\n        to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\r\n        copies of the Software, and to permit persons to whom the Software is\r\n        furnished to do so, subject to the following conditions:\r\n        \r\n        The above copyright notice and this permission notice shall be included in all\r\n        copies or substantial portions of the Software.\r\n        \r\n        THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\r\n        IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\r\n        FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\r\n        AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\r\n        LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\r\n        OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\r\n        SOFTWARE.\r\n        ",
    "summary": "Consolidated handler for subprocess logging",
    "version": "0.3.0",
    "project_urls": {
        "Homepage": "https://github.com/Vi-Nk/subprocess-logger/"
    },
    "split_keywords": [
        "subprocess",
        " logging",
        " loggers"
    ],
    "urls": [
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "49cd5995d7a71145ec8b342af1c6be0c06067d98f673f3c11cccde3adcd14b93",
                "md5": "d393f662ba98b0378668a3cc94044fdc",
                "sha256": "03a1fdd2cd985fcfba810b915bcdf77f3b938eec4f6c12efbbb42335c21e312c"
            },
            "downloads": -1,
            "filename": "subprocess_logger-0.3.0-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "d393f662ba98b0378668a3cc94044fdc",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.7",
            "size": 5159,
            "upload_time": "2025-09-12T14:28:25",
            "upload_time_iso_8601": "2025-09-12T14:28:25.911436Z",
            "url": "https://files.pythonhosted.org/packages/49/cd/5995d7a71145ec8b342af1c6be0c06067d98f673f3c11cccde3adcd14b93/subprocess_logger-0.3.0-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "b557084e1afd45d16f9c5ae7de3cd52e8b79dacdb45f10155020df217c35db3d",
                "md5": "48cb1c700cdd0b7bf234a4246da99683",
                "sha256": "348639f5429642f28cf5652f210e9f66719aa0c0d2d13ad2d688fd84a94ae734"
            },
            "downloads": -1,
            "filename": "subprocess_logger-0.3.0.tar.gz",
            "has_sig": false,
            "md5_digest": "48cb1c700cdd0b7bf234a4246da99683",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.7",
            "size": 5307,
            "upload_time": "2025-09-12T14:28:26",
            "upload_time_iso_8601": "2025-09-12T14:28:26.901403Z",
            "url": "https://files.pythonhosted.org/packages/b5/57/084e1afd45d16f9c5ae7de3cd52e8b79dacdb45f10155020df217c35db3d/subprocess_logger-0.3.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2025-09-12 14:28:26",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "Vi-Nk",
    "github_project": "subprocess-logger",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": false,
    "requirements": [
        {
            "name": "pytest",
            "specs": []
        },
        {
            "name": "wheel",
            "specs": []
        },
        {
            "name": "setuptools",
            "specs": []
        }
    ],
    "tox": true,
    "lcname": "subprocess-logger"
}
        
Elapsed time: 1.59133s