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
Built Distribution
File details
Details for the file click_logging_config-0.0.0.post9.tar.gz
.
File metadata
- Download URL: click_logging_config-0.0.0.post9.tar.gz
- Upload date:
- Size: 14.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.8.15
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | f35f934cf8c8fe7991b276bc3c37cd24e92f15028b74f48d5888141fb4679b71 |
|
MD5 | 805562270c8c51b5f03f581aa8ba3d58 |
|
BLAKE2b-256 | b9ccc3abbccbef11553d9c8cdc6743c1acf6f4c539994a3ba46a0c830c55b78e |
File details
Details for the file click_logging_config-0.0.0.post9-py3-none-any.whl
.
File metadata
- Download URL: click_logging_config-0.0.0.post9-py3-none-any.whl
- Upload date:
- Size: 7.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.8.15
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | edb5be1b0a2394c7a67c88804de0876caeb4086c043ee357c209f7ac126a27d5 |
|
MD5 | 3e0dfd2f68887a952e85938da9d9ad9f |
|
BLAKE2b-256 | 6acac7260561fef88eadc8e81fde48f230ac238529bb642ad5890e356f269ec9 |