crashvb-logging-utilities
Overview
Consolidation of logging utilities.
Installation
From pypi.org
$ pip install crashvb-logging-utilities
From source code
$ 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
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
Metadata
Release files for crashvb-logging-utilities 0.1.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| crashvb_logging_utilities-0.1.1.tar.gz | 8.2 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| crashvb_logging_utilities-0.1.1-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 17.3 kB
Release files / crashvb_logging_utilities-0.1.1.tar.gz
| Download URL | crashvb_logging_utilities-0.1.1.tar.gz |
|---|---|
| Size | 8.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
8fe4694229ea451c179df6e6194b20d84ff4a44c3f100914188f303d1aa12ec4
|
|
BLAKE2b-256 checksum How to use checksums |
d910749cd4cfe12fa4bd9cb6b969f5e09eb8403dfc0da1da8d5f57273d595b00
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/5.1.1 CPython/3.10.4
|
Release files / crashvb_logging_utilities-0.1.1-py3-none-any.whl
| Download URL | crashvb_logging_utilities-0.1.1-py3-none-any.whl |
|---|---|
| Size | 9.1 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
3493096c5fe1916c0c1ce31d27ebaee27ac3d052e832d9a9da7f977321586be8
|
|
BLAKE2b-256 checksum How to use checksums |
b187decc2289163142b68d6ca04e00f931bc7ea87a40742fa2904d223bd5815f
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/5.1.1 CPython/3.10.4
|