Metadata-Version: 2.1
Name: click_logging_config
Version: 0.2.1
Summary: Quick and easy logging parameters for click commands.
Home-page: https://gitlab.com/ci-cd-devops/click_logging_config
Author: Russell Smiley
Author-email: russell@bytingchipmunk.com
Requires-Python: >=3.7
Description-Content-Type: text/x-rst
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python :: 3 :: Only
Classifier: Typing :: Typed
Requires-Dist: click >=8.1.3, <9
Requires-Dist: json_log_formatter >=0.5.1, <1
Requires-Dist: pendulum >=2.1.2, <3
Requires-Dist: pydantic >=1.10.2, <2
Requires-Dist: pytz >=2022.6
Requires-Dist: build_harness >=2, <3 ; extra == "dev"
Requires-Dist: pre_commit >=2.13.0, <3 ; extra == "dev"
Requires-Dist: types-pytz >=2022.6.0.1 ; extra == "dev"
Requires-Dist: sphinx >=4.5.0, <5 ; extra == "doc"
Requires-Dist: sphinx_rtd_theme >=1.0, <2 ; extra == "doc"
Requires-Dist: pytest >=7.1.1, <8 ; extra == "test"
Requires-Dist: pytest-cov >=3.0, <4 ; extra == "test"
Requires-Dist: pytest-mock >=3.6.1, <4 ; extra == "test"
Provides-Extra: dev
Provides-Extra: doc
Provides-Extra: test

click_logging_config
====================

Quick and easy logging parameters for click commands.


.. contents::

.. section-numbering::


Installation
------------

The ``click_logging_config`` package is available from PyPI. Installing
into a virtual environment is recommended.

.. code-block::

   python3 -m venv .venv; .venv/bin/pip install click_logging_config


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.

.. code-block::

   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.

