crashvb-logging-utilities


Namecrashvb-logging-utilities JSON
Version 0.1.1 PyPI version JSON
download
home_pagehttps://pypi.org/project/crashvb-logging-utilities/
SummaryConsolidation of logging utilities.
upload_time2024-08-25 21:43:14
maintainerNone
docs_urlNone
authorRichard Davis
requires_pythonNone
licenseApache License 2.0
keywords crashvb logging utilities
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # crashvb-logging-utilities

[![pypi version](https://img.shields.io/pypi/v/crashvb-logging-utilities.svg)](https://pypi.org/project/crashvb-logging-utilities)
[![build status](https://github.com/server27nw/crashvb-logging-utilities/actions/workflows/main.yml/badge.svg)](https://github.com/server27nw/crashvb-logging-utilities/actions)
[![coverage status](https://coveralls.io/repos/github/server27nw/crashvb-logging-utilities/badge.svg)](https://coveralls.io/github/server27nw/crashvb-logging-utilities)
[![python versions](https://img.shields.io/pypi/pyversions/crashvb-logging-utilities.svg?logo=python&logoColor=FBE072)](https://pypi.org/project/crashvb-logging-utilities)
[![linting](https://img.shields.io/badge/linting-pylint-yellowgreen)](https://github.com/PyCQA/pylint)
[![code style](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/psf/black)
[![license](https://img.shields.io/github/license/server27nw/crashvb-logging-utilities.svg)](https://github.com/server27nw/crashvb-logging-utilities/blob/master/LICENSE.md)

## Overview

Consolidation of logging utilities.

## Installation
### From [pypi.org](https://pypi.org/project/crashvb-logging-utilities/)

```
$ pip install crashvb-logging-utilities
```

### From source code

```bash
$ git clone https://github.com/server27nw/crashvb-logging-utilities
$ cd crashvb-logging-utilities
$ virtualenv env
$ source env/bin/activate
$ python -m pip install --editable .[dev]
```

## Usage

```python
import click
import logging
import sys
from traceback import print_exception
from typing import NamedTuple

from click.core import Context
from crashvb_logging_utilities import LOGGING_DEFAULT, logging_options, set_log_levels

LOGGER = logging.getLogger(__name__)

class TypingContextObject(NamedTuple):
    # pylint: disable=missing-class-docstring
    ...
    verbosity: int

@click.group()
@logging_options
@click.pass_context
def cli(
    context: Context,
    verbosity: int = LOGGING_DEFAULT,
):
    """Main group."""

    if verbosity is None:
        verbosity = LOGGING_DEFAULT

    set_log_levels(verbosity)

    context.obj = TypingContextObject(
        # ...
        verbosity=verbosity,
    )

@cli.command(name="command1", ...)
@click.option( ... )
@click.pass_context
def command1(context: Context, ...):
    """Command #1"""
    ctx = context.obj
    try:
	    ...
    except Exception as exception:  # pylint: disable=broad-except
        if ctx.verbosity > 0:
            logging.fatal(exception)
        if ctx.verbosity > LOGGING_DEFAULT:
            exc_info = sys.exc_info()
            print_exception(*exc_info)
        sys.exit(1)
    
```

### Environment Variables

| Variable | Default Value | Description |
| ---------| ------------- | ----------- |

## Development

[Source Control](https://github.com/server27nw/crashvb-logging-utilities)



            

Raw data

            {
    "_id": null,
    "home_page": "https://pypi.org/project/crashvb-logging-utilities/",
    "name": "crashvb-logging-utilities",
    "maintainer": null,
    "docs_url": null,
    "requires_python": null,
    "maintainer_email": null,
    "keywords": "crashvb logging utilities",
    "author": "Richard Davis",
    "author_email": "crashvb@gmail.com",
    "download_url": "https://files.pythonhosted.org/packages/d9/10/749cd4cfe12fa4bd9cb6b969f5e09eb8403dfc0da1da8d5f57273d595b00/crashvb_logging_utilities-0.1.1.tar.gz",
    "platform": null,
    "description": "# crashvb-logging-utilities\n\n[![pypi version](https://img.shields.io/pypi/v/crashvb-logging-utilities.svg)](https://pypi.org/project/crashvb-logging-utilities)\n[![build status](https://github.com/server27nw/crashvb-logging-utilities/actions/workflows/main.yml/badge.svg)](https://github.com/server27nw/crashvb-logging-utilities/actions)\n[![coverage status](https://coveralls.io/repos/github/server27nw/crashvb-logging-utilities/badge.svg)](https://coveralls.io/github/server27nw/crashvb-logging-utilities)\n[![python versions](https://img.shields.io/pypi/pyversions/crashvb-logging-utilities.svg?logo=python&logoColor=FBE072)](https://pypi.org/project/crashvb-logging-utilities)\n[![linting](https://img.shields.io/badge/linting-pylint-yellowgreen)](https://github.com/PyCQA/pylint)\n[![code style](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/psf/black)\n[![license](https://img.shields.io/github/license/server27nw/crashvb-logging-utilities.svg)](https://github.com/server27nw/crashvb-logging-utilities/blob/master/LICENSE.md)\n\n## Overview\n\nConsolidation of logging utilities.\n\n## Installation\n### From [pypi.org](https://pypi.org/project/crashvb-logging-utilities/)\n\n```\n$ pip install crashvb-logging-utilities\n```\n\n### From source code\n\n```bash\n$ git clone https://github.com/server27nw/crashvb-logging-utilities\n$ cd crashvb-logging-utilities\n$ virtualenv env\n$ source env/bin/activate\n$ python -m pip install --editable .[dev]\n```\n\n## Usage\n\n```python\nimport click\nimport logging\nimport sys\nfrom traceback import print_exception\nfrom typing import NamedTuple\n\nfrom click.core import Context\nfrom crashvb_logging_utilities import LOGGING_DEFAULT, logging_options, set_log_levels\n\nLOGGER = logging.getLogger(__name__)\n\nclass TypingContextObject(NamedTuple):\n    # pylint: disable=missing-class-docstring\n    ...\n    verbosity: int\n\n@click.group()\n@logging_options\n@click.pass_context\ndef cli(\n    context: Context,\n    verbosity: int = LOGGING_DEFAULT,\n):\n    \"\"\"Main group.\"\"\"\n\n    if verbosity is None:\n        verbosity = LOGGING_DEFAULT\n\n    set_log_levels(verbosity)\n\n    context.obj = TypingContextObject(\n        # ...\n        verbosity=verbosity,\n    )\n\n@cli.command(name=\"command1\", ...)\n@click.option( ... )\n@click.pass_context\ndef command1(context: Context, ...):\n    \"\"\"Command #1\"\"\"\n    ctx = context.obj\n    try:\n\t    ...\n    except Exception as exception:  # pylint: disable=broad-except\n        if ctx.verbosity > 0:\n            logging.fatal(exception)\n        if ctx.verbosity > LOGGING_DEFAULT:\n            exc_info = sys.exc_info()\n            print_exception(*exc_info)\n        sys.exit(1)\n    \n```\n\n### Environment Variables\n\n| Variable | Default Value | Description |\n| ---------| ------------- | ----------- |\n\n## Development\n\n[Source Control](https://github.com/server27nw/crashvb-logging-utilities)\n\n\n",
    "bugtrack_url": null,
    "license": "Apache License 2.0",
    "summary": "Consolidation of logging utilities.",
    "version": "0.1.1",
    "project_urls": {
        "Bug Reports": "https://github.com/server27nw/crashvb-logging-utilities/issues",
        "Homepage": "https://pypi.org/project/crashvb-logging-utilities/",
        "Source": "https://github.com/server27nw/crashvb-logging-utilities"
    },
    "split_keywords": [
        "crashvb",
        "logging",
        "utilities"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "b187decc2289163142b68d6ca04e00f931bc7ea87a40742fa2904d223bd5815f",
                "md5": "b54b8a6562f67d68f675eafb95995b38",
                "sha256": "3493096c5fe1916c0c1ce31d27ebaee27ac3d052e832d9a9da7f977321586be8"
            },
            "downloads": -1,
            "filename": "crashvb_logging_utilities-0.1.1-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "b54b8a6562f67d68f675eafb95995b38",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": null,
            "size": 9075,
            "upload_time": "2024-08-25T21:43:13",
            "upload_time_iso_8601": "2024-08-25T21:43:13.066569Z",
            "url": "https://files.pythonhosted.org/packages/b1/87/decc2289163142b68d6ca04e00f931bc7ea87a40742fa2904d223bd5815f/crashvb_logging_utilities-0.1.1-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "d910749cd4cfe12fa4bd9cb6b969f5e09eb8403dfc0da1da8d5f57273d595b00",
                "md5": "5def40d684141433e91e9ab0e88d6697",
                "sha256": "8fe4694229ea451c179df6e6194b20d84ff4a44c3f100914188f303d1aa12ec4"
            },
            "downloads": -1,
            "filename": "crashvb_logging_utilities-0.1.1.tar.gz",
            "has_sig": false,
            "md5_digest": "5def40d684141433e91e9ab0e88d6697",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": null,
            "size": 8197,
            "upload_time": "2024-08-25T21:43:14",
            "upload_time_iso_8601": "2024-08-25T21:43:14.357531Z",
            "url": "https://files.pythonhosted.org/packages/d9/10/749cd4cfe12fa4bd9cb6b969f5e09eb8403dfc0da1da8d5f57273d595b00/crashvb_logging_utilities-0.1.1.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-08-25 21:43:14",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "server27nw",
    "github_project": "crashvb-logging-utilities",
    "github_not_found": true,
    "lcname": "crashvb-logging-utilities"
}
        
Elapsed time: 0.68959s