diff --git a/click_log/core.py b/click_log/core.py index 722f092..fe70e20 100644 --- a/click_log/core.py +++ b/click_log/core.py @@ -49,7 +49,6 @@ class ClickHandler(logging.Handler): def emit(self, record): try: msg = self.format(record) - level = record.levelname.lower() click.echo(msg, err=self._use_stderr) except Exception: self.handleError(record) diff --git a/docs/conf.py b/docs/conf.py index b8085bc..893b802 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -1,6 +1,5 @@ # -*- coding: utf-8 -*- -import sys import os import click_log @@ -28,7 +27,6 @@ try: import sphinx_rtd_theme html_theme = 'sphinx_rtd_theme' - html_theme_path = [sphinx_rtd_theme.get_html_theme_path()] except ImportError: html_theme = 'default' if not on_rtd: @@ -37,7 +35,7 @@ 'theme.') print('-' * 74) -html_static_path = ['_static'] +# html_static_path = ['_static'] htmlhelp_basename = 'click-logdoc' latex_elements = {} diff --git a/docs/index.rst b/docs/index.rst index f3e22f3..9e47220 100644 --- a/docs/index.rst +++ b/docs/index.rst @@ -9,6 +9,11 @@ Click-log: Simple and beautiful logging for click applications .. module:: click_log + +.. contents:: Table of contents + +---- + Getting started =============== @@ -83,13 +88,50 @@ The output will look like this:: error: Failed to divide by zero. -The ``error:``-prefix will be red, unless the output is piped to another +---- + +Customization +============= + +Output colors ++++++++++++++ + +In the Getting started example, the ``error:`` prefix will be red, unless the output is piped to another command. -The :py:func:`simple_verbosity_option` decorator adds a ``--verbosity`` option -that takes a (case-insensitive) value of ``DEBUG``, ``INFO``, ``WARNING``, -``ERROR``, or ``CRITICAL``, and calls ``setLevel`` on the given logger -accordingly. +Default colors: + ++------------+---------+ +| Log level | Color | ++============+=========+ +| critical | red | ++------------+---------+ +| debug | blue | ++------------+---------+ +| error | red | ++------------+---------+ +| exception | red | ++------------+---------+ +| warning | yellow | ++------------+---------+ + +To customize colors used by each level of log, it's possible to pass a dict with the foreground color for each log level. +Color code must be `one of those included into click `_ + +For example: + +.. code-block:: python + + import logging + import click_log + + click_log.ColorFormatter.colors['info'] = dict(fg="bright_black") + + +Simple verbosity +++++++++++++++++ + +In the Getting started example, the :py:func:`simple_verbosity_option` decorator adds a ``--verbosity`` option that takes a (case-insensitive) value of ``DEBUG``, ``INFO``, ``WARNING``, ``ERROR``, or ``CRITICAL``, and calls ``setLevel`` on the given logger accordingly. .. note:: @@ -97,6 +139,8 @@ accordingly. Otherwise logging setup will not be early enough for some of your other eager options. +---- + API === diff --git a/setup.py b/setup.py index 13528f1..980fb57 100644 --- a/setup.py +++ b/setup.py @@ -44,4 +44,7 @@ install_requires=[ 'click', ], + extras_require={ + "doc": ["sphinx>=3.2,<3.3", "sphinx-rtd-theme>=0.5,<0.6"], + }, )