Like `subprocess.run`, but with the ability to pipe `stdout` and/or `stderr` to a `Logger` or capture each stream independently while the process is running.
Project description
run_with_logger
Like subprocess.run, but with the ability to pipe stdout and/or stderr to a Logger or capture each stream
independently while the process is running.
Examples
Log stderr and capture stdout
The main process will wait for the subprocess while:
- forwarding
stderrline by line to the logger - capturing
stdoutin aCompletedProcessobject, which is returned when the process finishes
from run_with_logger import run_with_logger
from logging import getLogger
logger = getLogger(__name__)
completed = run_with_logger(
args=['foo', 'bar'],
logger=logger,
stdout_action="capture",
stderr_action="log",
check=False,
)
print(completed.stdout)
Log stdout and discard stderr
The main process will wait for the subprocess while:
- forwarding
stdoutline by line to the logger - discarding
stderr
from run_with_logger import run_with_logger
from logging import getLogger
logger = getLogger(__name__)
completed = run_with_logger(
args=['foo', 'bar'],
logger=logger,
stdout_action="log",
stderr_action="discard",
check=False,
)
print(completed.stdout)
Project details
Release history Release notifications | RSS feed
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
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file run_with_logger-1.4.2.tar.gz.
File metadata
- Download URL: run_with_logger-1.4.2.tar.gz
- Upload date:
- Size: 13.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
47e8ce5a23ecfb704cf807bb756ece16b2dc51040bd150a14ebd65efa826ba59
|
|
| MD5 |
ae53fbbd0960f6eee913cdd785759cea
|
|
| BLAKE2b-256 |
c45135d5f2e528b0bd729f3447f9364322a6430442a8c3bffa6d50170d2c35fc
|
Provenance
The following attestation bundles were made for run_with_logger-1.4.2.tar.gz:
Publisher:
publish.yml on rudolfbyker/run_with_logger
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
run_with_logger-1.4.2.tar.gz -
Subject digest:
47e8ce5a23ecfb704cf807bb756ece16b2dc51040bd150a14ebd65efa826ba59 - Sigstore transparency entry: 1067035367
- Sigstore integration time:
-
Permalink:
rudolfbyker/run_with_logger@009307c296aa3d92fb4e82ee1f9a828fad84e31c -
Branch / Tag:
refs/tags/1.4.2 - Owner: https://github.com/rudolfbyker
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@009307c296aa3d92fb4e82ee1f9a828fad84e31c -
Trigger Event:
release
-
Statement type:
File details
Details for the file run_with_logger-1.4.2-py3-none-any.whl.
File metadata
- Download URL: run_with_logger-1.4.2-py3-none-any.whl
- Upload date:
- Size: 9.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5409684e5e87ee4008b67111c514d0cfdb8b36c4bac7242b6e5c5d90bef99ce3
|
|
| MD5 |
e1cb42500df72e2f6cc51f11af60a224
|
|
| BLAKE2b-256 |
d034d59553d260e8c34b9c40a4ed063431dd18001f687e7a9b8f9662eb192916
|
Provenance
The following attestation bundles were made for run_with_logger-1.4.2-py3-none-any.whl:
Publisher:
publish.yml on rudolfbyker/run_with_logger
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
run_with_logger-1.4.2-py3-none-any.whl -
Subject digest:
5409684e5e87ee4008b67111c514d0cfdb8b36c4bac7242b6e5c5d90bef99ce3 - Sigstore transparency entry: 1067035456
- Sigstore integration time:
-
Permalink:
rudolfbyker/run_with_logger@009307c296aa3d92fb4e82ee1f9a828fad84e31c -
Branch / Tag:
refs/tags/1.4.2 - Owner: https://github.com/rudolfbyker
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@009307c296aa3d92fb4e82ee1f9a828fad84e31c -
Trigger Event:
release
-
Statement type: