libsrg


Namelibsrg JSON
Version 4.2.3 PyPI version JSON
download
home_pagehttps://gitlab.com/SRG_gitlab/libsrg
SummaryBase class for logging apps, Nagios, utilities
upload_time2024-04-21 12:43:15
maintainerNone
docs_urlNone
authorSteven Goncalo
requires_python>=3.9
licenseNone
keywords
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            ## 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 <file> 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
Core functionality appears solid, but naming and packaging may be fluid for a while.

This is my first attempt at publishing to pypi, so there may be surprises. 

I will bump version to 1.x when out of beta.

            

Raw data

            {
    "_id": null,
    "home_page": "https://gitlab.com/SRG_gitlab/libsrg",
    "name": "libsrg",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.9",
    "maintainer_email": null,
    "keywords": null,
    "author": "Steven Goncalo",
    "author_email": "srg_pypi@ice9mail.com",
    "download_url": null,
    "platform": null,
    "description": "## Name\nlibsrg -- count calls to python logging at each logging severity level\n\n## Description\nlibsrg provides the following classes:\n* libsrg.LoggingCounter\n  * extends logging.Handler with count of logs at each severity level\n  * counts on output, so logs suppressed by current logging level do not get counted\n  * atexit hook used to print statistics on program exit\n* libsrg.LoggingAppBase\n  * application base class with LoggingCounter installed\n  * argparse.ArgumentParser\n    * --verbose sets logging level to DEBUG\n    * --logfile <file> directs logging to a file\n  * Derived classes can add application specific options to ArgumentParser\n* libsrg.Runner\n  * run command line in a subprocess\n  * capture stdout, stderr\n  * try catch block for exceptions\n  * exceptions can optionally be raised back to calling program\n\nI write a lot of smallish command line utilities for internal use, and factored out some common \nrepetitive boilerplate code into this package. Published for my own installation convenience, \nbut might be useful to others as well. \n\n## Example output\n\nLibrary uses atexit hook to summarize logging activity counts and total execution time. \nCounts are also available to the program at runtime.\n```\n2022-02-22 12:46:22,568 INFO     (libsrg.LoggingCounter:61) __log_atexit \nLogging Summary:\nLogging at Level INFO       occurred         13 times\nLogging at Level DEBUG      occurred          1 times\nLogging at Level WARNING    occurred          1 times\nLogging at Level ERROR      occurred          2 times\nLogging at Level CRITICAL   occurred          1 times\nElapsed time was 0.087 seconds\n```\n\n## Internal notes on updating\n\n* /GNAS/PROJ/PycharmProjects/libsrg/publish.bash\n```\n#! /bin/bash\n\ncd /GNAS/PROJ/PycharmProjects/libsrg\nrm -rf dist\npython3 -m build --wheel\npython3 -m twine check dist/*\npython3 -m twine upload dist/*\n```\n\n## Installation from pypi via pip\n* pip3 install libsrg\n* pip3 install libsrg --update\n\n## Installation from Gitlab or local repository\n* pip3 install git+ssh://git@gitlab.com/SRG_gitlab/libsrg.git\n* pip3 install /GNAS/PROJ/PycharmProjects/libsrg\n\n## Testing\n\nPytest performs its own logging setup before calling any user supplied tests, so it\ndoesn't work well testing these classes logging setup. Ad-hoc test code is supplied\nat the end of the classes and executes if the class is loaded as __main__.\n\n\n## Roadmap\nMy intention is to keep this library small. It is not expected to evolve into an all-purpose framework. \nOutput is geared towards developers, not end users. \n\n## License\nMIT\n\n## Project status\nCore functionality appears solid, but naming and packaging may be fluid for a while.\n\nThis is my first attempt at publishing to pypi, so there may be surprises. \n\nI will bump version to 1.x when out of beta.\n",
    "bugtrack_url": null,
    "license": null,
    "summary": "Base class for logging apps, Nagios, utilities",
    "version": "4.2.3",
    "project_urls": {
        "Homepage": "https://gitlab.com/SRG_gitlab/libsrg"
    },
    "split_keywords": [],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "df431938c12eca919c212c8d630c9f5b6d3bb0ae54f1c3b2e428a9fc4f7e0b9b",
                "md5": "3b326306efff470ddf6396224b2d7426",
                "sha256": "9a05982771f049f229427b6f865ac6111b9ac6f1efd3f4baece9bd0f06aa1f2a"
            },
            "downloads": -1,
            "filename": "libsrg-4.2.3-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "3b326306efff470ddf6396224b2d7426",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.9",
            "size": 55093,
            "upload_time": "2024-04-21T12:43:15",
            "upload_time_iso_8601": "2024-04-21T12:43:15.561771Z",
            "url": "https://files.pythonhosted.org/packages/df/43/1938c12eca919c212c8d630c9f5b6d3bb0ae54f1c3b2e428a9fc4f7e0b9b/libsrg-4.2.3-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-04-21 12:43:15",
    "github": false,
    "gitlab": true,
    "bitbucket": false,
    "codeberg": false,
    "gitlab_user": "SRG_gitlab",
    "gitlab_project": "libsrg",
    "lcname": "libsrg"
}
        
Elapsed time: 0.21795s