Metadata-Version: 2.4
Name: subprocess-logger
Version: 0.3.0
Summary: Consolidated handler for subprocess logging
Home-page: https://github.com/Vi-Nk/subprocess-logger/
Author: Vi-Nk
License: MIT 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
Classifier: Programming Language :: Python :: 3
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: OS Independent
Classifier: Development Status :: 4 - Beta
Classifier: Intended Audience :: Developers
Classifier: Topic :: Software Development :: Libraries :: Python Modules
Requires-Python: >=3.7
Description-Content-Type: text/markdown
License-File: LICENSE
Dynamic: home-page
Dynamic: license-file
Dynamic: requires-python

# 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.
