Quick and easy logging parameters for click commands.
Project description
Quick and easy logging parameters for click commands.
1 Installation
The click_logging_config package is available from PyPI. Installing into a virtual environment is recommended.
python3 -m venv .venv; .venv/bin/pip install click_logging_config
2 Getting Started
Using click_logging_config is intended to be very simple. A single decorator applied to your click command or group adds some click options specifically for managing logging context.
import click
import logging
from click_logging import logging_parameters
log = logging.getLogger(__name__)
def do_something()
@click.command()
# NOTE: Empty braces required for hard-coded click_logging.parameters defaults.
@click.option("--my-option", type=str)
@logging_parameters()
def my_command(my_option: str) -> None:
log.info("doing something")
try:
do_something(my_option)
except Exception as e:
log.critical(f"something bad happened, {str(e)}")
raise
Application of @logging_parameters decorator must be applied immediately above your click command function and below any other click decorators such as arguments and options.
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
click_logging_config-0.2.1.tar.gz
(15.4 kB
view hashes)
Built Distribution
Close
Hashes for click_logging_config-0.2.1.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 969d5fec3011bb614627cc4ea9a6154a98bf97f0d132e3912e1c2114531c431e |
|
MD5 | a9ec4553e3b350c298260816e04e037b |
|
BLAKE2b-256 | 1ee9bf70c2ac1ebfdffb83055e9f3d5307e0f4d620452ebc9e5e99f78cab94e9 |
Close
Hashes for click_logging_config-0.2.1-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 13ad6a82f4977d1b8e90baa624fd0856ace78db73a28c8c88f4e3d5da9e29243 |
|
MD5 | be2e2024d9c962a5ec08e6c75f622d52 |
|
BLAKE2b-256 | fd2e1a0534d6cf4b0ab8147d07017e2da5714e71e7bab30f9554ae3647b5a0e2 |