From 424f900ad60e066b125934497e8041587423e0d9 Mon Sep 17 00:00:00 2001 From: Julien Date: Tue, 17 Nov 2020 11:06:22 +0100 Subject: [PATCH 1/8] Flake8 - local variable 'level' is assigned to but never used --- click_log/core.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/click_log/core.py b/click_log/core.py index 722f092..0de0273 100644 --- a/click_log/core.py +++ b/click_log/core.py @@ -49,7 +49,7 @@ class ClickHandler(logging.Handler): def emit(self, record): try: msg = self.format(record) - level = record.levelname.lower() + # level = record.levelname.lower() click.echo(msg, err=self._use_stderr) except Exception: self.handleError(record) From a16b14153cdfd345d53144106a422a809474f707 Mon Sep 17 00:00:00 2001 From: Julien Date: Tue, 17 Nov 2020 11:06:36 +0100 Subject: [PATCH 2/8] flake8 - sys imported but never used --- docs/conf.py | 1 - 1 file changed, 1 deletion(-) diff --git a/docs/conf.py b/docs/conf.py index b8085bc..323afa2 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -1,6 +1,5 @@ # -*- coding: utf-8 -*- -import sys import os import click_log From 2acfcf9a6ecc1b4b9e764abd0c94c8122dad7f6f Mon Sep 17 00:00:00 2001 From: Julien Date: Tue, 17 Nov 2020 11:10:25 +0100 Subject: [PATCH 3/8] Add requirements for doc build --- setup.py | 3 +++ 1 file changed, 3 insertions(+) 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"], + }, ) From e5ebac9e0e8980804fd73ccf95d9823379d04c8a Mon Sep 17 00:00:00 2001 From: Julien Date: Tue, 17 Nov 2020 11:10:43 +0100 Subject: [PATCH 4/8] Comment not used static path --- docs/conf.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/conf.py b/docs/conf.py index 323afa2..e3ed8d0 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -36,7 +36,7 @@ 'theme.') print('-' * 74) -html_static_path = ['_static'] +# html_static_path = ['_static'] htmlhelp_basename = 'click-logdoc' latex_elements = {} From 2340926e6c209eee9684e1fbe6ffd27ab283b8df Mon Sep 17 00:00:00 2001 From: Julien Date: Tue, 17 Nov 2020 11:26:28 +0100 Subject: [PATCH 5/8] Remove useless html_theme_path --- docs/conf.py | 1 - 1 file changed, 1 deletion(-) diff --git a/docs/conf.py b/docs/conf.py index e3ed8d0..893b802 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -27,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: From 081e1dc22c6c3cba7720892bec96c7f3ed634d93 Mon Sep 17 00:00:00 2001 From: Julien Date: Tue, 17 Nov 2020 11:27:24 +0100 Subject: [PATCH 6/8] Doc how to custom output olors - #19 --- docs/index.rst | 34 +++++++++++++++++++++++++++++++++- 1 file changed, 33 insertions(+), 1 deletion(-) diff --git a/docs/index.rst b/docs/index.rst index f3e22f3..b6b934a 100644 --- a/docs/index.rst +++ b/docs/index.rst @@ -83,13 +83,45 @@ 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 +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") + + .. note:: From e597150bf52e1556353f4200cbe61e024daa78fa Mon Sep 17 00:00:00 2001 From: Julien Date: Tue, 17 Nov 2020 11:27:43 +0100 Subject: [PATCH 7/8] Improve page structure and nav --- docs/index.rst | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/docs/index.rst b/docs/index.rst index b6b934a..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,16 +88,17 @@ The output will look like this:: error: Failed to divide by zero. +---- + +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: +------------+---------+ @@ -122,6 +128,10 @@ For example: 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:: @@ -129,6 +139,8 @@ For example: Otherwise logging setup will not be early enough for some of your other eager options. +---- + API === From 5c96d4d6425b4efca55f686081de61e576576a61 Mon Sep 17 00:00:00 2001 From: Julien Date: Mon, 30 Nov 2020 22:37:55 +0100 Subject: [PATCH 8/8] Update click_log/core.py Co-authored-by: Markus Unterwaditzer --- click_log/core.py | 1 - 1 file changed, 1 deletion(-) diff --git a/click_log/core.py b/click_log/core.py index 0de0273..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)