Skip to main content

Name

libsrg -- count calls to python logging at each logging severity level

Description

libsrg provides the following classes:

  • libsrg.LoggingCounter
    • extends logging.Handler with count of logs at each severity level
    • counts on output, so logs suppressed by current logging level do not get counted
    • atexit hook used to print statistics on program exit
  • libsrg.LoggingAppBase
    • application base class with LoggingCounter installed
    • argparse.ArgumentParser
      • --verbose sets logging level to DEBUG
      • --logfile directs logging to a file
    • Derived classes can add application specific options to ArgumentParser
  • libsrg.Runner
    • run command line in a subprocess
    • capture stdout, stderr
    • try catch block for exceptions
    • exceptions can optionally be raised back to calling program

I write a lot of smallish command line utilities for internal use, and factored out some common repetitive boilerplate code into this package. Published for my own installation convenience, but might be useful to others as well.

Example output

Library uses atexit hook to summarize logging activity counts and total execution time. Counts are also available to the program at runtime.

2022-02-22 12:46:22,568 INFO     (libsrg.LoggingCounter:61) __log_atexit 
Logging Summary:
Logging at Level INFO       occurred         13 times
Logging at Level DEBUG      occurred          1 times
Logging at Level WARNING    occurred          1 times
Logging at Level ERROR      occurred          2 times
Logging at Level CRITICAL   occurred          1 times
Elapsed time was 0.087 seconds

Internal notes on updating

  • /GNAS/PROJ/PycharmProjects/libsrg/publish.bash
#! /bin/bash

cd /GNAS/PROJ/PycharmProjects/libsrg
rm -rf dist
python3 -m build --wheel
python3 -m twine check dist/*
python3 -m twine upload dist/*

Installation from pypi via pip

  • pip3 install libsrg
  • pip3 install libsrg --update

Installation from Gitlab or local repository

  • pip3 install git+ssh://git@gitlab.com/SRG_gitlab/libsrg.git
  • pip3 install /GNAS/PROJ/PycharmProjects/libsrg

Testing

Pytest performs its own logging setup before calling any user supplied tests, so it doesn't work well testing these classes logging setup. Ad-hoc test code is supplied at the end of the classes and executes if the class is loaded as main.

Roadmap

My intention is to keep this library small. It is not expected to evolve into an all-purpose framework. Output is geared towards developers, not end users.

License

MIT

Project status

Pulled extraneous applications out into libsrg_apps

Metadata

Release files for libsrg 26.11.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for libsrg 26.11.0
File Size Uploaded Provenance Actions
libsrg-26.11.0.tar.gz 28.7 kB Without provenance Details for libsrg-26.11.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for libsrg 26.11.0
File Interpreter ABI Platform Actions
libsrg-26.11.0-py3-none-any.whl Python 3 none any Details for libsrg-26.11.0-py3-none-any.whl

Total release size: 67.6 kB

Release files / libsrg-26.11.0.tar.gz

Download URL libsrg-26.11.0.tar.gz
Size 28.7 kB
Tags Source
SHA-256 checksum
How to use checksums
09a21f19f2e50db0a3850154cfc9ff1cf1de43bbc86abe4079dcca4dcf025595
BLAKE2b-256 checksum
How to use checksums
bab450c197395f58149f36810d19f849e024c5b31c719a29dfc3af35664d476d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.5.27

Release files / libsrg-26.11.0-py3-none-any.whl

Download URL libsrg-26.11.0-py3-none-any.whl
Size 38.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
dda4cf069ebdb2ae3cea457f4fac5b602f416ddce4cb169097bdb6ecb2463c42
BLAKE2b-256 checksum
How to use checksums
721aafca2c2da1df678bc6c9fa11fb73b20fd2f660ce26c18ae83e47ce620772
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.5.27

Security for libsrg 26.11.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

26.11.0 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page