{"id":18084970,"url":"https://github.com/jwodder/click-loglevel","last_synced_at":"2025-04-12T20:11:28.741Z","repository":{"id":60721974,"uuid":"334748294","full_name":"jwodder/click-loglevel","owner":"jwodder","description":"Log level parameter type for Click","archived":false,"fork":false,"pushed_at":"2025-02-11T15:06:26.000Z","size":67,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-28T23:35:39.590Z","etag":null,"topics":["available-on-pypi","cli-option","click","command-line-interface","log-level","log-option","logging","option-parsing","python"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/jwodder.png","metadata":{"files":{"readme":"README.rst","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2021-01-31T20:18:35.000Z","updated_at":"2025-02-11T15:06:30.000Z","dependencies_parsed_at":"2023-01-31T01:55:13.296Z","dependency_job_id":"3c2ecb98-20bc-4604-9ec6-09bdd0de1615","html_url":"https://github.com/jwodder/click-loglevel","commit_stats":{"total_commits":42,"total_committers":1,"mean_commits":42.0,"dds":0.0,"last_synced_commit":"3ae423236c3234e5fa0c45830278a0f3522e41af"},"previous_names":[],"tags_count":8,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jwodder%2Fclick-loglevel","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jwodder%2Fclick-loglevel/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jwodder%2Fclick-loglevel/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jwodder%2Fclick-loglevel/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jwodder","download_url":"https://codeload.github.com/jwodder/click-loglevel/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248625493,"owners_count":21135513,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["available-on-pypi","cli-option","click","command-line-interface","log-level","log-option","logging","option-parsing","python"],"created_at":"2024-10-31T15:08:49.793Z","updated_at":"2025-04-12T20:11:28.713Z","avatar_url":"https://github.com/jwodder.png","language":"Python","readme":"|repostatus| |ci-status| |coverage| |pyversions| |conda| |license|\n\n.. |repostatus| image:: https://www.repostatus.org/badges/latest/active.svg\n    :target: https://www.repostatus.org/#active\n    :alt: Project Status: Active — The project has reached a stable, usable\n          state and is being actively developed.\n\n.. |ci-status| image:: https://github.com/jwodder/click-loglevel/actions/workflows/test.yml/badge.svg\n    :target: https://github.com/jwodder/click-loglevel/actions/workflows/test.yml\n    :alt: CI Status\n\n.. |coverage| image:: https://codecov.io/gh/jwodder/click-loglevel/branch/master/graph/badge.svg\n    :target: https://codecov.io/gh/jwodder/click-loglevel\n\n.. |pyversions| image:: https://img.shields.io/pypi/pyversions/click-loglevel.svg\n    :target: https://pypi.org/project/click-loglevel/\n\n.. |conda| image:: https://img.shields.io/conda/vn/conda-forge/click-loglevel.svg\n    :target: https://anaconda.org/conda-forge/click-loglevel\n    :alt: Conda Version\n\n.. |license| image:: https://img.shields.io/github/license/jwodder/click-loglevel.svg\n    :target: https://opensource.org/licenses/MIT\n    :alt: MIT License\n\n`GitHub \u003chttps://github.com/jwodder/click-loglevel\u003e`_\n| `PyPI \u003chttps://pypi.org/project/click-loglevel/\u003e`_\n| `Issues \u003chttps://github.com/jwodder/click-loglevel/issues\u003e`_\n| `Changelog \u003chttps://github.com/jwodder/click-loglevel/blob/master/CHANGELOG.md\u003e`_\n\n``click-loglevel`` provides a ``LogLevel`` parameter type for use in Click_ and\nasyncclick_ programs that wish to let the user set the logging level.  It\naccepts all of the ``logging`` log level names (``CRITICAL``, ``ERROR``,\n``WARNING``, ``INFO``, ``DEBUG``, and ``NOTSET``, all case insensitive), and\nconverts them into their corresponding numeric values.  It also accepts integer\nvalues and leaves them as-is.  Custom log levels are also supported.\n\nStarting in version 0.4.0, shell completion of log level names (both built-in\nand custom) is also supported.\n\n.. _Click: https://palletsprojects.com/p/click/\n.. _asyncclick: https://github.com/python-trio/asyncclick\n\n\nInstallation\n============\n``click-loglevel`` requires Python 3.8 or higher.  Just use `pip\n\u003chttps://pip.pypa.io\u003e`_ for Python 3 (You have pip, right?) to install it::\n\n    python3 -m pip install click-loglevel\n\n\nExamples\n========\n\n``myscript.py``:\n\n.. code:: python\n\n    import logging\n    import click\n    from click_loglevel import LogLevel\n\n\n    @click.command()\n    @click.option(\n        \"-l\",\n        \"--log-level\",\n        type=LogLevel(),\n        default=\"INFO\",\n        help=\"Set logging level\",\n        show_default=True,\n    )\n    def main(log_level: int) -\u003e None:\n        logging.basicConfig(\n            format=\"[%(levelname)-8s] %(message)s\",\n            level=log_level,\n        )\n        logging.log(log_level, \"Log level set to %r\", log_level)\n\n\n    if __name__ == \"__main__\":\n        main()\n\nRunning ``myscript.py``:\n\n.. code:: console\n\n    $ python3 myscript.py\n    [INFO    ] Log level set to 20\n    $ python3 myscript.py --log-level DEBUG\n    [DEBUG   ] Log level set to 10\n    $ python3 myscript.py --log-level error\n    [ERROR   ] Log level set to 40\n    $ python3 myscript.py --log-level 15\n    [Level 15] Log level set to 15\n\nScript with custom log levels:\n\n.. code:: python\n\n    import logging\n    import click\n    from click_loglevel import LogLevel\n\n\n    logging.addLevelName(15, \"VERBOSE\")\n    logging.addLevelName(25, \"NOTICE\")\n\n\n    @click.command()\n    @click.option(\n        \"-l\",\n        \"--log-level\",\n        type=LogLevel(extra=[\"VERBOSE\", \"NOTICE\"]),\n        default=\"INFO\",\n        help=\"Set logging level\",\n        show_default=True,\n    )\n    def main(log_level: int) -\u003e None:\n        logging.basicConfig(\n            format=\"[%(levelname)-8s] %(message)s\",\n            level=log_level,\n        )\n        logging.log(log_level, \"Log level set to %r\", log_level)\n\n\n    if __name__ == \"__main__\":\n        main()\n\n\nAPI\n===\n\nThe ``click_loglevel`` module contains a single class:\n\n``LogLevel``\n------------\n\nA subclass of ``click.ParamType`` that accepts the standard logging level names\n(case insensitive) and converts them to their corresponding numeric values.  It\nalso accepts integer values and leaves them as-is.\n\nCustom log levels can be added by passing them as the ``extra`` argument to the\nconstructor.  ``extra`` can be either an iterable of level names (in which case\nthe levels must have already been defined — typically at the module level — by\ncalling ``logging.addLevelName()``) or a mapping from level names to their\ncorresponding values.  All custom log levels will be recognized case\ninsensitively; if two different level names differ only in case, the result is\nundefined.\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjwodder%2Fclick-loglevel","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjwodder%2Fclick-loglevel","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjwodder%2Fclick-loglevel/lists"}