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.0.tar.gz
.
File metadata
- Download URL: crashvb_logging_utilities-0.1.0.tar.gz
- Upload date:
- Size: 8.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.10.4
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | ddb441739a558f5b85f4cf2ff7ea66b2b3845ee7225a35277e9a58bdb0e988a4 |
|
MD5 | 29b15fc766368ca4444dddff61e9ae37 |
|
BLAKE2b-256 | 56439f1f0ad037a1081e763ff9e06833f6779950c4dc0382e1562439ad1c4c64 |
File details
Details for the file crashvb_logging_utilities-0.1.0-py3-none-any.whl
.
File metadata
- Download URL: crashvb_logging_utilities-0.1.0-py3-none-any.whl
- Upload date:
- Size: 8.9 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 | 92e38742a729c82c11f9e2a5f679646ef5b841a40575437a51240cf2aeb9e75e |
|
MD5 | a8541b76bbb5742256a6023c7882ba7d |
|
BLAKE2b-256 | 67b5fc90154a1b045e998359e40a6f3c365692dd08c94b12a5123b9857e038fb |