https://github.com/sandialabs/shell-logger
A Python package that allows you to interact with the shell, while logging various metadata, statistics, and trace information.
https://github.com/sandialabs/shell-logger
replicability reproducibility scr-2873 scripting snl-build-tools snl-comp-science-libs snl-other snl-performance-workflow
Last synced: about 1 year ago
JSON representation
A Python package that allows you to interact with the shell, while logging various metadata, statistics, and trace information.
- Host: GitHub
- URL: https://github.com/sandialabs/shell-logger
- Owner: sandialabs
- License: other
- Created: 2024-02-13T19:17:53.000Z (over 2 years ago)
- Default Branch: master
- Last Pushed: 2025-04-24T13:02:37.000Z (about 1 year ago)
- Last Synced: 2025-04-24T14:23:15.587Z (about 1 year ago)
- Topics: replicability, reproducibility, scr-2873, scripting, snl-build-tools, snl-comp-science-libs, snl-other, snl-performance-workflow
- Language: Python
- Homepage: https://shell-logger.readthedocs.io
- Size: 1.51 MB
- Stars: 2
- Watchers: 2
- Forks: 1
- Open Issues: 23
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- Contributing: CONTRIBUTING.md
- License: LICENSE.md
- Code of conduct: CODE_OF_CONDUCT.md
- Security: SECURITY.md
Awesome Lists containing this project
README

[](https://codecov.io/gh/sandialabs/shell-logger)
[](https://www.codefactor.io/repository/github/sandialabs/shell-logger/overview/master)
[](https://github.com/sandialabs/shell-logger/actions/workflows/github-code-scanning/codeql)
[](https://github.com/sandialabs/shell-logger/actions/workflows/continuous-integration.yml)
[](CODE_OF_CONDUCT.md)
[](https://github.com/sandialabs/shell-logger/graphs/contributors)
[](https://shell-logger.readthedocs.io/en/latest/?badge=latest)
[](LICENSE.md)
[](https://github.com/sandialabs/shell-logger/pulls?q=is:pr+is:merged)
[](https://bestpractices.coreinfrastructure.org/projects/8863)
[](https://securityscorecards.dev/viewer/?uri=github.com/sandialabs/shell-logger)

[](https://github.com/pre-commit/pre-commit)
[](https://results.pre-commit.ci/latest/github/sandialabs/shell-logger/master)
[](https://pypi.org/project/shell-logger-sandialabs/)


[](https://github.com/astral-sh/ruff)
> **NOTICE:** After using this package for a few years, we realized we'd
> attempted to do too many things at once with it. It still provides
> tremendous functionality for a wide variety of use cases, but for particular
> corner cases, it became apparent that design decisions made early on were
> hampering forward progress, and we wouldn't recommend doing things the same
> way today. Certain aspects of its functionality have inspired more focused
> packages ([reverse-argparse][reverse-argparse],
> [staged-script][staged-script]), and we hope to do the same with more
> functionality in the future. For the time being, though, don't expect much
> development and maintenance here. That said, if you use `shell-logger` and
> are eager to contribute to its longevity, let us know.
[reverse-argparse]: https://github.com/sandialabs/reverse_argparse
[staged-script]: https://github.com/sandialabs/staged-script
# shell-logger
The `shell-logger` Python package allows you to interact with the shell, while
logging various metadata, statistics, and trace information. Any time you're
tempted to write your own wrapper around things like `subprocess.Popen()` or
`subprocess.run()`, consider using `shell_logger.ShellLogger.log()` instead.
If you're familiar with [the Unix script command][script], this is similar in
principle, but with substantially more functionality. If you're familiar with
[Python's logging module][logging], the motivation is similar, but this intends
to capture what's happening *in the shell* rather than in Python itself.
[script]: https://man7.org/linux/man-pages/man1/script.1.html
[logging]: https://docs.python.org/3/library/logging.html
## Installation
To get up and running with `shell-logger`, simply:
```bash
python3 -m pip install shell-logger-sandialabs
```
## Usage
Once the package is installed, you can simply
```python
from shell_logger import ShellLogger
sl = ShellLogger("Title of Log File")
sl.log("Execute my first command in the shell.", "echo 'Hello World'")
sl.finalize()
```
For more detailed usage and API information, please see
[our documentation][readthedocs].
[readthedocs]: https://shell-logger.readthedocs.io
## Where to Get Help
If you're having trouble with `shell-logger`, or just want to ask a question,
head on over to [our issue board][issues]. If a quick search doesn't yield
what you're looking for, feel free to file an issue.
[issues]: https://github.com/sandialabs/shell-logger/issues
## Contributing
If you're interested in contributing to the development of `shell-logger`, we'd
love to have your help :grinning: Check out our
[contributing guidelines](CONTRIBUTING.md) for how to get started.
[Past contributors][contributors] include:
* [@bbraunj](https://github.com/bbraunj)
* [@sswan](https://github.com/sswan)
* [@dc-snl](https://github.com/dc-snl)
* [@jmgate](https://github.com/jmgate)
* [@mvlopri](https://github.com/mvlopri)
[contributors]: https://github.com/sandialabs/shell-logger/graphs/contributors
## License & Copyright
See [LICENSE.md](LICENSE.md) and [COPYRIGHT.md](COPYRIGHT.md).
## Credits
Special thanks to the EMPIRE project for investing in the initial development
of this tool, and [the GMS project][gms] for serving as a second user and
contributing to its clean-up.
[gms]: https://github.com/SNL-GMS/GMS-PI25