Consolidation of logging utilities.
Project description
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
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file crashvb_logging_utilities-0.1.1.tar.gz
.
File metadata
- Download URL: crashvb_logging_utilities-0.1.1.tar.gz
- Upload date:
- Size: 8.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.10.4
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 8fe4694229ea451c179df6e6194b20d84ff4a44c3f100914188f303d1aa12ec4 |
|
MD5 | 5def40d684141433e91e9ab0e88d6697 |
|
BLAKE2b-256 | d910749cd4cfe12fa4bd9cb6b969f5e09eb8403dfc0da1da8d5f57273d595b00 |
File details
Details for the file crashvb_logging_utilities-0.1.1-py3-none-any.whl
.
File metadata
- Download URL: crashvb_logging_utilities-0.1.1-py3-none-any.whl
- Upload date:
- Size: 9.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.10.4
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3493096c5fe1916c0c1ce31d27ebaee27ac3d052e832d9a9da7f977321586be8 |
|
MD5 | b54b8a6562f67d68f675eafb95995b38 |
|
BLAKE2b-256 | b187decc2289163142b68d6ca04e00f931bc7ea87a40742fa2904d223bd5815f |