pax_global_header 0000666 0000000 0000000 00000000064 13305714506 0014516 g ustar 00root root 0000000 0000000 52 comment=0d72a212ae7a45ab890d6e88a690679f8b946937
click-log-0.3.2/ 0000775 0000000 0000000 00000000000 13305714506 0013364 5 ustar 00root root 0000000 0000000 click-log-0.3.2/.gitignore 0000664 0000000 0000000 00000000157 13305714506 0015357 0 ustar 00root root 0000000 0000000 .DS_Store
*.pyc
*.pyo
*.egg-ignore
*.egg-info
dist
build/
docs/_build
click.egg-info
.tox
.cache
.pytest_cache
click-log-0.3.2/.travis.yml 0000664 0000000 0000000 00000000163 13305714506 0015475 0 ustar 00root root 0000000 0000000 language: python
python:
- 2.7
- pypy
- 3.4
- 3.5
- 3.6
install: pip install tox
script: tox
click-log-0.3.2/LICENSE 0000664 0000000 0000000 00000002074 13305714506 0014374 0 ustar 00root root 0000000 0000000 Copyright (c) 2014-2015 Markus Unterwaditzer & contributors
Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
of the Software, and to permit persons to whom the Software is furnished to do
so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
click-log-0.3.2/MANIFEST.in 0000664 0000000 0000000 00000000230 13305714506 0015115 0 ustar 00root root 0000000 0000000 include LICENSE
include Makefile
recursive-include docs *
recursive-include tests *
prune docs/_build
global-exclude *.py[cdo] __pycache__ *.so *.pyd
click-log-0.3.2/Makefile 0000664 0000000 0000000 00000000063 13305714506 0015023 0 ustar 00root root 0000000 0000000 release:
python setup.py sdist bdist_wheel upload
click-log-0.3.2/README.rst 0000664 0000000 0000000 00000000555 13305714506 0015060 0 ustar 00root root 0000000 0000000 click-log
=========
.. image:: https://travis-ci.org/click-contrib/click-log.svg?branch=master
:target: https://travis-ci.org/click-contrib/click-log
Integrates logging with click.
- `Documentation `_
- `Source code `_
License
=======
Licensed under the MIT, see ``LICENSE``.
click-log-0.3.2/click_log/ 0000775 0000000 0000000 00000000000 13305714506 0015312 5 ustar 00root root 0000000 0000000 click-log-0.3.2/click_log/__init__.py 0000664 0000000 0000000 00000000447 13305714506 0017430 0 ustar 00root root 0000000 0000000 # -*- coding: utf-8 -*-
# flake8: noqa
import click
__version__ = '0.3.2'
if not hasattr(click, 'get_current_context'):
raise RuntimeError('You need Click 5.0.')
from .core import (
ClickHandler,
ColorFormatter,
basic_config,
)
from .options import simple_verbosity_option
click-log-0.3.2/click_log/core.py 0000664 0000000 0000000 00000003450 13305714506 0016616 0 ustar 00root root 0000000 0000000 # -*- coding: utf-8 -*-
import logging
import sys
import click
_ctx = click.get_current_context
LOGGER_KEY = __name__ + '.logger'
DEFAULT_LEVEL = logging.INFO
PY2 = sys.version_info[0] == 2
if PY2:
text_type = unicode # noqa
else:
text_type = str
def _meta():
return _ctx().meta.setdefault(LOGGER_KEY, {})
class ColorFormatter(logging.Formatter):
colors = {
'error': dict(fg='red'),
'exception': dict(fg='red'),
'critical': dict(fg='red'),
'debug': dict(fg='blue'),
'warning': dict(fg='yellow')
}
def format(self, record):
if not record.exc_info:
level = record.levelname.lower()
msg = record.getMessage()
if level in self.colors:
prefix = click.style('{}: '.format(level),
**self.colors[level])
msg = '\n'.join(prefix + x for x in msg.splitlines())
return msg
return logging.Formatter.format(self, record)
class ClickHandler(logging.Handler):
_use_stderr = True
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)
_default_handler = ClickHandler()
_default_handler.formatter = ColorFormatter()
def _normalize_logger(logger):
if not isinstance(logger, logging.Logger):
logger = logging.getLogger(logger)
return logger
def basic_config(logger=None):
'''Set up the default handler (:py:class:`ClickHandler`) and formatter
(:py:class:`ColorFormatter`) on the given logger.'''
logger = _normalize_logger(logger)
logger.handlers = [_default_handler]
logger.propagate = False
return logger
click-log-0.3.2/click_log/options.py 0000664 0000000 0000000 00000002376 13305714506 0017367 0 ustar 00root root 0000000 0000000 import logging
import click
from .core import _normalize_logger
def simple_verbosity_option(logger=None, *names, **kwargs):
'''A decorator that adds a `--verbosity, -v` option to the decorated
command.
Name can be configured through ``*names``. Keyword arguments are passed to
the underlying ``click.option`` decorator.
'''
if not names:
names = ['--verbosity', '-v']
if isinstance(logger, str) and logger.startswith('-'):
raise ValueError('Since click-log 0.2.0, the first argument must now '
'be a logger.')
kwargs.setdefault('default', 'INFO')
kwargs.setdefault('metavar', 'LVL')
kwargs.setdefault('expose_value', False)
kwargs.setdefault('help', 'Either CRITICAL, ERROR, WARNING, INFO or DEBUG')
kwargs.setdefault('is_eager', True)
logger = _normalize_logger(logger)
def decorator(f):
def _set_level(ctx, param, value):
x = getattr(logging, value.upper(), None)
if x is None:
raise click.BadParameter(
'Must be CRITICAL, ERROR, WARNING, INFO or DEBUG, not {}'
)
logger.setLevel(x)
return click.option(*names, callback=_set_level, **kwargs)(f)
return decorator
click-log-0.3.2/docs/ 0000775 0000000 0000000 00000000000 13305714506 0014314 5 ustar 00root root 0000000 0000000 click-log-0.3.2/docs/Makefile 0000664 0000000 0000000 00000017614 13305714506 0015765 0 ustar 00root root 0000000 0000000 # Makefile for Sphinx documentation
#
# You can set these variables from the command line.
SPHINXOPTS =
SPHINXBUILD = sphinx-build
PAPER =
BUILDDIR = _build
# User-friendly check for sphinx-build
ifeq ($(shell which $(SPHINXBUILD) >/dev/null 2>&1; echo $$?), 1)
$(error The '$(SPHINXBUILD)' command was not found. Make sure you have Sphinx installed, then set the SPHINXBUILD environment variable to point to the full path of the '$(SPHINXBUILD)' executable. Alternatively you can add the directory with the executable to your PATH. If you don\'t have Sphinx installed, grab it from http://sphinx-doc.org/)
endif
# Internal variables.
PAPEROPT_a4 = -D latex_paper_size=a4
PAPEROPT_letter = -D latex_paper_size=letter
ALLSPHINXOPTS = -d $(BUILDDIR)/doctrees $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) .
# the i18n builder cannot share the environment and doctrees with the others
I18NSPHINXOPTS = $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) .
.PHONY: help
help:
@echo "Please use \`make ' where is one of"
@echo " html to make standalone HTML files"
@echo " dirhtml to make HTML files named index.html in directories"
@echo " singlehtml to make a single large HTML file"
@echo " pickle to make pickle files"
@echo " json to make JSON files"
@echo " htmlhelp to make HTML files and a HTML help project"
@echo " qthelp to make HTML files and a qthelp project"
@echo " applehelp to make an Apple Help Book"
@echo " devhelp to make HTML files and a Devhelp project"
@echo " epub to make an epub"
@echo " epub3 to make an epub3"
@echo " latex to make LaTeX files, you can set PAPER=a4 or PAPER=letter"
@echo " latexpdf to make LaTeX files and run them through pdflatex"
@echo " latexpdfja to make LaTeX files and run them through platex/dvipdfmx"
@echo " text to make text files"
@echo " man to make manual pages"
@echo " texinfo to make Texinfo files"
@echo " info to make Texinfo files and run them through makeinfo"
@echo " gettext to make PO message catalogs"
@echo " changes to make an overview of all changed/added/deprecated items"
@echo " xml to make Docutils-native XML files"
@echo " pseudoxml to make pseudoxml-XML files for display purposes"
@echo " linkcheck to check all external links for integrity"
@echo " doctest to run all doctests embedded in the documentation (if enabled)"
@echo " coverage to run coverage check of the documentation (if enabled)"
@echo " dummy to check syntax errors of document sources"
.PHONY: clean
clean:
rm -rf $(BUILDDIR)/*
.PHONY: html
html:
$(SPHINXBUILD) -b html $(ALLSPHINXOPTS) $(BUILDDIR)/html
@echo
@echo "Build finished. The HTML pages are in $(BUILDDIR)/html."
.PHONY: dirhtml
dirhtml:
$(SPHINXBUILD) -b dirhtml $(ALLSPHINXOPTS) $(BUILDDIR)/dirhtml
@echo
@echo "Build finished. The HTML pages are in $(BUILDDIR)/dirhtml."
.PHONY: singlehtml
singlehtml:
$(SPHINXBUILD) -b singlehtml $(ALLSPHINXOPTS) $(BUILDDIR)/singlehtml
@echo
@echo "Build finished. The HTML page is in $(BUILDDIR)/singlehtml."
.PHONY: pickle
pickle:
$(SPHINXBUILD) -b pickle $(ALLSPHINXOPTS) $(BUILDDIR)/pickle
@echo
@echo "Build finished; now you can process the pickle files."
.PHONY: json
json:
$(SPHINXBUILD) -b json $(ALLSPHINXOPTS) $(BUILDDIR)/json
@echo
@echo "Build finished; now you can process the JSON files."
.PHONY: htmlhelp
htmlhelp:
$(SPHINXBUILD) -b htmlhelp $(ALLSPHINXOPTS) $(BUILDDIR)/htmlhelp
@echo
@echo "Build finished; now you can run HTML Help Workshop with the" \
".hhp project file in $(BUILDDIR)/htmlhelp."
.PHONY: qthelp
qthelp:
$(SPHINXBUILD) -b qthelp $(ALLSPHINXOPTS) $(BUILDDIR)/qthelp
@echo
@echo "Build finished; now you can run "qcollectiongenerator" with the" \
".qhcp project file in $(BUILDDIR)/qthelp, like this:"
@echo "# qcollectiongenerator $(BUILDDIR)/qthelp/click-log.qhcp"
@echo "To view the help file:"
@echo "# assistant -collectionFile $(BUILDDIR)/qthelp/click-log.qhc"
.PHONY: applehelp
applehelp:
$(SPHINXBUILD) -b applehelp $(ALLSPHINXOPTS) $(BUILDDIR)/applehelp
@echo
@echo "Build finished. The help book is in $(BUILDDIR)/applehelp."
@echo "N.B. You won't be able to view it unless you put it in" \
"~/Library/Documentation/Help or install it in your application" \
"bundle."
.PHONY: devhelp
devhelp:
$(SPHINXBUILD) -b devhelp $(ALLSPHINXOPTS) $(BUILDDIR)/devhelp
@echo
@echo "Build finished."
@echo "To view the help file:"
@echo "# mkdir -p $$HOME/.local/share/devhelp/click-log"
@echo "# ln -s $(BUILDDIR)/devhelp $$HOME/.local/share/devhelp/click-log"
@echo "# devhelp"
.PHONY: epub
epub:
$(SPHINXBUILD) -b epub $(ALLSPHINXOPTS) $(BUILDDIR)/epub
@echo
@echo "Build finished. The epub file is in $(BUILDDIR)/epub."
.PHONY: epub3
epub3:
$(SPHINXBUILD) -b epub3 $(ALLSPHINXOPTS) $(BUILDDIR)/epub3
@echo
@echo "Build finished. The epub3 file is in $(BUILDDIR)/epub3."
.PHONY: latex
latex:
$(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex
@echo
@echo "Build finished; the LaTeX files are in $(BUILDDIR)/latex."
@echo "Run \`make' in that directory to run these through (pdf)latex" \
"(use \`make latexpdf' here to do that automatically)."
.PHONY: latexpdf
latexpdf:
$(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex
@echo "Running LaTeX files through pdflatex..."
$(MAKE) -C $(BUILDDIR)/latex all-pdf
@echo "pdflatex finished; the PDF files are in $(BUILDDIR)/latex."
.PHONY: latexpdfja
latexpdfja:
$(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex
@echo "Running LaTeX files through platex and dvipdfmx..."
$(MAKE) -C $(BUILDDIR)/latex all-pdf-ja
@echo "pdflatex finished; the PDF files are in $(BUILDDIR)/latex."
.PHONY: text
text:
$(SPHINXBUILD) -b text $(ALLSPHINXOPTS) $(BUILDDIR)/text
@echo
@echo "Build finished. The text files are in $(BUILDDIR)/text."
.PHONY: man
man:
$(SPHINXBUILD) -b man $(ALLSPHINXOPTS) $(BUILDDIR)/man
@echo
@echo "Build finished. The manual pages are in $(BUILDDIR)/man."
.PHONY: texinfo
texinfo:
$(SPHINXBUILD) -b texinfo $(ALLSPHINXOPTS) $(BUILDDIR)/texinfo
@echo
@echo "Build finished. The Texinfo files are in $(BUILDDIR)/texinfo."
@echo "Run \`make' in that directory to run these through makeinfo" \
"(use \`make info' here to do that automatically)."
.PHONY: info
info:
$(SPHINXBUILD) -b texinfo $(ALLSPHINXOPTS) $(BUILDDIR)/texinfo
@echo "Running Texinfo files through makeinfo..."
make -C $(BUILDDIR)/texinfo info
@echo "makeinfo finished; the Info files are in $(BUILDDIR)/texinfo."
.PHONY: gettext
gettext:
$(SPHINXBUILD) -b gettext $(I18NSPHINXOPTS) $(BUILDDIR)/locale
@echo
@echo "Build finished. The message catalogs are in $(BUILDDIR)/locale."
.PHONY: changes
changes:
$(SPHINXBUILD) -b changes $(ALLSPHINXOPTS) $(BUILDDIR)/changes
@echo
@echo "The overview file is in $(BUILDDIR)/changes."
.PHONY: linkcheck
linkcheck:
$(SPHINXBUILD) -b linkcheck $(ALLSPHINXOPTS) $(BUILDDIR)/linkcheck
@echo
@echo "Link check complete; look for any errors in the above output " \
"or in $(BUILDDIR)/linkcheck/output.txt."
.PHONY: doctest
doctest:
$(SPHINXBUILD) -b doctest $(ALLSPHINXOPTS) $(BUILDDIR)/doctest
@echo "Testing of doctests in the sources finished, look at the " \
"results in $(BUILDDIR)/doctest/output.txt."
.PHONY: coverage
coverage:
$(SPHINXBUILD) -b coverage $(ALLSPHINXOPTS) $(BUILDDIR)/coverage
@echo "Testing of coverage in the sources finished, look at the " \
"results in $(BUILDDIR)/coverage/python.txt."
.PHONY: xml
xml:
$(SPHINXBUILD) -b xml $(ALLSPHINXOPTS) $(BUILDDIR)/xml
@echo
@echo "Build finished. The XML files are in $(BUILDDIR)/xml."
.PHONY: pseudoxml
pseudoxml:
$(SPHINXBUILD) -b pseudoxml $(ALLSPHINXOPTS) $(BUILDDIR)/pseudoxml
@echo
@echo "Build finished. The pseudo-XML files are in $(BUILDDIR)/pseudoxml."
.PHONY: dummy
dummy:
$(SPHINXBUILD) -b dummy $(ALLSPHINXOPTS) $(BUILDDIR)/dummy
@echo
@echo "Build finished. Dummy builder generates no files."
click-log-0.3.2/docs/conf.py 0000664 0000000 0000000 00000002520 13305714506 0015612 0 ustar 00root root 0000000 0000000 # -*- coding: utf-8 -*-
import sys
import os
import click_log
extensions = ['sphinx.ext.autodoc']
templates_path = ['_templates']
source_suffix = '.rst'
master_doc = 'index'
project = 'click-log'
copyright = '2016, Markus Unterwaditzer & contributors'
author = 'Markus Unterwaditzer & contributors'
release = click_log.__version__
version = '.'.join(release.split('.')[:2]) # The short X.Y version.
exclude_patterns = ['_build']
pygments_style = 'sphinx'
on_rtd = os.environ.get('READTHEDOCS', None) == 'True'
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:
print('-' * 74)
print('Warning: sphinx-rtd-theme not installed, building with default '
'theme.')
print('-' * 74)
html_static_path = ['_static']
htmlhelp_basename = 'click-logdoc'
latex_elements = {}
latex_documents = [
(master_doc, 'click-log.tex', 'click-log Documentation',
'Markus Unterwaditzer \\& contributors', 'manual'),
]
man_pages = [
(master_doc, 'click-log', 'click-log Documentation',
[author], 1)
]
texinfo_documents = [
(master_doc, 'click-log', 'click-log Documentation',
author, 'click-log', 'One line description of project.',
'Miscellaneous'),
]
click-log-0.3.2/docs/index.rst 0000664 0000000 0000000 00000005573 13305714506 0016167 0 ustar 00root root 0000000 0000000 ==============================================================
Click-log: Simple and beautiful logging for click applications
==============================================================
.. include:: ../README.rst
.. toctree::
:maxdepth: 2
.. module:: click_log
Getting started
===============
Assuming you have this Click application::
@click.command()
def cli():
click.echo("Dividing by zero.")
try:
1 / 0
except:
click.echo("ERROR: Failed to divide by zero.")
Ignore the application's core functionality for a moment. The much more
pressing question here is: How do we add an option to not print anything on
success? We could try this::
@click.command()
@click.option('--quiet', default=False, is_flag=True)
def cli(quiet):
if not quiet:
click.echo("Dividing by zero.")
try:
1 / 0
except:
click.echo("ERROR: Failed to divide by zero.")
Wrapping if-statements around each ``echo``-call is cumbersome though. And with
that, we discover logging::
import logging
logger = logging.getLogger(__name__)
# More setup for logging handlers here
@click.command()
@click.option('--quiet', default=False, is_flag=True)
def cli(quiet):
if quiet:
logger.setLevel(logging.ERROR)
else:
logger.setLevel(logging.INFO)
...
Logging is a better solution, but partly because Python's logging module aims
to be so generic, it doesn't come with sensible defaults for CLI applications.
At some point you might also want to expose more logging levels through more
options, at which point the boilerplate code grows even more.
This is where click-log comes in::
import logging
logger = logging.getLogger(__name__)
click_log.basic_config(logger)
@click.command()
@click_log.simple_verbosity_option(logger)
def cli():
logger.info("Dividing by zero.")
try:
1 / 0
except:
logger.error("Failed to divide by zero.")
The output will look like this::
Dividing by zero.
error: Failed to divide by zero.
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.
.. note::
Make sure to define the `simple_verbosity_option` as early as possible.
Otherwise logging setup will not be early enough for some of your other
eager options.
API
===
.. autofunction:: basic_config
.. autofunction:: simple_verbosity_option
Classes
-------
.. autoclass:: ClickHandler
.. autoclass:: ColorFormatter
Indices and tables
==================
* :ref:`genindex`
* :ref:`modindex`
* :ref:`search`
click-log-0.3.2/docs/make.bat 0000664 0000000 0000000 00000017072 13305714506 0015730 0 ustar 00root root 0000000 0000000 @ECHO OFF
REM Command file for Sphinx documentation
if "%SPHINXBUILD%" == "" (
set SPHINXBUILD=sphinx-build
)
set BUILDDIR=_build
set ALLSPHINXOPTS=-d %BUILDDIR%/doctrees %SPHINXOPTS% .
set I18NSPHINXOPTS=%SPHINXOPTS% .
if NOT "%PAPER%" == "" (
set ALLSPHINXOPTS=-D latex_paper_size=%PAPER% %ALLSPHINXOPTS%
set I18NSPHINXOPTS=-D latex_paper_size=%PAPER% %I18NSPHINXOPTS%
)
if "%1" == "" goto help
if "%1" == "help" (
:help
echo.Please use `make ^` where ^ is one of
echo. html to make standalone HTML files
echo. dirhtml to make HTML files named index.html in directories
echo. singlehtml to make a single large HTML file
echo. pickle to make pickle files
echo. json to make JSON files
echo. htmlhelp to make HTML files and a HTML help project
echo. qthelp to make HTML files and a qthelp project
echo. devhelp to make HTML files and a Devhelp project
echo. epub to make an epub
echo. epub3 to make an epub3
echo. latex to make LaTeX files, you can set PAPER=a4 or PAPER=letter
echo. text to make text files
echo. man to make manual pages
echo. texinfo to make Texinfo files
echo. gettext to make PO message catalogs
echo. changes to make an overview over all changed/added/deprecated items
echo. xml to make Docutils-native XML files
echo. pseudoxml to make pseudoxml-XML files for display purposes
echo. linkcheck to check all external links for integrity
echo. doctest to run all doctests embedded in the documentation if enabled
echo. coverage to run coverage check of the documentation if enabled
echo. dummy to check syntax errors of document sources
goto end
)
if "%1" == "clean" (
for /d %%i in (%BUILDDIR%\*) do rmdir /q /s %%i
del /q /s %BUILDDIR%\*
goto end
)
REM Check if sphinx-build is available and fallback to Python version if any
%SPHINXBUILD% 1>NUL 2>NUL
if errorlevel 9009 goto sphinx_python
goto sphinx_ok
:sphinx_python
set SPHINXBUILD=python -m sphinx.__init__
%SPHINXBUILD% 2> nul
if errorlevel 9009 (
echo.
echo.The 'sphinx-build' command was not found. Make sure you have Sphinx
echo.installed, then set the SPHINXBUILD environment variable to point
echo.to the full path of the 'sphinx-build' executable. Alternatively you
echo.may add the Sphinx directory to PATH.
echo.
echo.If you don't have Sphinx installed, grab it from
echo.http://sphinx-doc.org/
exit /b 1
)
:sphinx_ok
if "%1" == "html" (
%SPHINXBUILD% -b html %ALLSPHINXOPTS% %BUILDDIR%/html
if errorlevel 1 exit /b 1
echo.
echo.Build finished. The HTML pages are in %BUILDDIR%/html.
goto end
)
if "%1" == "dirhtml" (
%SPHINXBUILD% -b dirhtml %ALLSPHINXOPTS% %BUILDDIR%/dirhtml
if errorlevel 1 exit /b 1
echo.
echo.Build finished. The HTML pages are in %BUILDDIR%/dirhtml.
goto end
)
if "%1" == "singlehtml" (
%SPHINXBUILD% -b singlehtml %ALLSPHINXOPTS% %BUILDDIR%/singlehtml
if errorlevel 1 exit /b 1
echo.
echo.Build finished. The HTML pages are in %BUILDDIR%/singlehtml.
goto end
)
if "%1" == "pickle" (
%SPHINXBUILD% -b pickle %ALLSPHINXOPTS% %BUILDDIR%/pickle
if errorlevel 1 exit /b 1
echo.
echo.Build finished; now you can process the pickle files.
goto end
)
if "%1" == "json" (
%SPHINXBUILD% -b json %ALLSPHINXOPTS% %BUILDDIR%/json
if errorlevel 1 exit /b 1
echo.
echo.Build finished; now you can process the JSON files.
goto end
)
if "%1" == "htmlhelp" (
%SPHINXBUILD% -b htmlhelp %ALLSPHINXOPTS% %BUILDDIR%/htmlhelp
if errorlevel 1 exit /b 1
echo.
echo.Build finished; now you can run HTML Help Workshop with the ^
.hhp project file in %BUILDDIR%/htmlhelp.
goto end
)
if "%1" == "qthelp" (
%SPHINXBUILD% -b qthelp %ALLSPHINXOPTS% %BUILDDIR%/qthelp
if errorlevel 1 exit /b 1
echo.
echo.Build finished; now you can run "qcollectiongenerator" with the ^
.qhcp project file in %BUILDDIR%/qthelp, like this:
echo.^> qcollectiongenerator %BUILDDIR%\qthelp\click-log.qhcp
echo.To view the help file:
echo.^> assistant -collectionFile %BUILDDIR%\qthelp\click-log.ghc
goto end
)
if "%1" == "devhelp" (
%SPHINXBUILD% -b devhelp %ALLSPHINXOPTS% %BUILDDIR%/devhelp
if errorlevel 1 exit /b 1
echo.
echo.Build finished.
goto end
)
if "%1" == "epub" (
%SPHINXBUILD% -b epub %ALLSPHINXOPTS% %BUILDDIR%/epub
if errorlevel 1 exit /b 1
echo.
echo.Build finished. The epub file is in %BUILDDIR%/epub.
goto end
)
if "%1" == "epub3" (
%SPHINXBUILD% -b epub3 %ALLSPHINXOPTS% %BUILDDIR%/epub3
if errorlevel 1 exit /b 1
echo.
echo.Build finished. The epub3 file is in %BUILDDIR%/epub3.
goto end
)
if "%1" == "latex" (
%SPHINXBUILD% -b latex %ALLSPHINXOPTS% %BUILDDIR%/latex
if errorlevel 1 exit /b 1
echo.
echo.Build finished; the LaTeX files are in %BUILDDIR%/latex.
goto end
)
if "%1" == "latexpdf" (
%SPHINXBUILD% -b latex %ALLSPHINXOPTS% %BUILDDIR%/latex
cd %BUILDDIR%/latex
make all-pdf
cd %~dp0
echo.
echo.Build finished; the PDF files are in %BUILDDIR%/latex.
goto end
)
if "%1" == "latexpdfja" (
%SPHINXBUILD% -b latex %ALLSPHINXOPTS% %BUILDDIR%/latex
cd %BUILDDIR%/latex
make all-pdf-ja
cd %~dp0
echo.
echo.Build finished; the PDF files are in %BUILDDIR%/latex.
goto end
)
if "%1" == "text" (
%SPHINXBUILD% -b text %ALLSPHINXOPTS% %BUILDDIR%/text
if errorlevel 1 exit /b 1
echo.
echo.Build finished. The text files are in %BUILDDIR%/text.
goto end
)
if "%1" == "man" (
%SPHINXBUILD% -b man %ALLSPHINXOPTS% %BUILDDIR%/man
if errorlevel 1 exit /b 1
echo.
echo.Build finished. The manual pages are in %BUILDDIR%/man.
goto end
)
if "%1" == "texinfo" (
%SPHINXBUILD% -b texinfo %ALLSPHINXOPTS% %BUILDDIR%/texinfo
if errorlevel 1 exit /b 1
echo.
echo.Build finished. The Texinfo files are in %BUILDDIR%/texinfo.
goto end
)
if "%1" == "gettext" (
%SPHINXBUILD% -b gettext %I18NSPHINXOPTS% %BUILDDIR%/locale
if errorlevel 1 exit /b 1
echo.
echo.Build finished. The message catalogs are in %BUILDDIR%/locale.
goto end
)
if "%1" == "changes" (
%SPHINXBUILD% -b changes %ALLSPHINXOPTS% %BUILDDIR%/changes
if errorlevel 1 exit /b 1
echo.
echo.The overview file is in %BUILDDIR%/changes.
goto end
)
if "%1" == "linkcheck" (
%SPHINXBUILD% -b linkcheck %ALLSPHINXOPTS% %BUILDDIR%/linkcheck
if errorlevel 1 exit /b 1
echo.
echo.Link check complete; look for any errors in the above output ^
or in %BUILDDIR%/linkcheck/output.txt.
goto end
)
if "%1" == "doctest" (
%SPHINXBUILD% -b doctest %ALLSPHINXOPTS% %BUILDDIR%/doctest
if errorlevel 1 exit /b 1
echo.
echo.Testing of doctests in the sources finished, look at the ^
results in %BUILDDIR%/doctest/output.txt.
goto end
)
if "%1" == "coverage" (
%SPHINXBUILD% -b coverage %ALLSPHINXOPTS% %BUILDDIR%/coverage
if errorlevel 1 exit /b 1
echo.
echo.Testing of coverage in the sources finished, look at the ^
results in %BUILDDIR%/coverage/python.txt.
goto end
)
if "%1" == "xml" (
%SPHINXBUILD% -b xml %ALLSPHINXOPTS% %BUILDDIR%/xml
if errorlevel 1 exit /b 1
echo.
echo.Build finished. The XML files are in %BUILDDIR%/xml.
goto end
)
if "%1" == "pseudoxml" (
%SPHINXBUILD% -b pseudoxml %ALLSPHINXOPTS% %BUILDDIR%/pseudoxml
if errorlevel 1 exit /b 1
echo.
echo.Build finished. The pseudo-XML files are in %BUILDDIR%/pseudoxml.
goto end
)
if "%1" == "dummy" (
%SPHINXBUILD% -b dummy %ALLSPHINXOPTS% %BUILDDIR%/dummy
if errorlevel 1 exit /b 1
echo.
echo.Build finished. Dummy builder generates no files.
goto end
)
:end
click-log-0.3.2/setup.cfg 0000664 0000000 0000000 00000000121 13305714506 0015177 0 ustar 00root root 0000000 0000000 [wheel]
universal = 1
[flake8]
# W503: Line break before operator
ignore = W503
click-log-0.3.2/setup.py 0000664 0000000 0000000 00000003034 13305714506 0015076 0 ustar 00root root 0000000 0000000 #!/usr/bin/env python
import ast
import re
from setuptools import setup
_version_re = re.compile(r'__version__\s+=\s+(.*)')
with open('click_log/__init__.py', 'rb') as f:
version = str(ast.literal_eval(_version_re.search(
f.read().decode('utf-8')).group(1)))
setup(
name='click-log',
version=version,
description='Logging integration for Click',
author='Markus Unterwaditzer',
author_email='markus@unterwaditzer.net',
url='https://github.com/click-contrib/click-log',
license='MIT',
long_description=open('README.rst').read(),
classifiers=[
# See: https://pypi.python.org/pypi?:action=list_classifiers
'Development Status :: 4 - Beta',
'Environment :: Console',
'Environment :: Plugins',
'Intended Audience :: Developers',
'License :: OSI Approved :: MIT License',
# List of python versions and their support status:
# https://en.wikipedia.org/wiki/CPython#Version_history
'Programming Language :: Python',
'Programming Language :: Python :: 2',
'Programming Language :: Python :: 2.7',
'Programming Language :: Python :: 3',
'Programming Language :: Python :: 3.3',
'Programming Language :: Python :: 3.4',
'Programming Language :: Python :: 3.5',
'Programming Language :: Python :: 3.6',
'Programming Language :: Python :: Implementation :: CPython',
'Topic :: System :: Logging',
],
packages=['click_log'],
install_requires=[
'click',
],
)
click-log-0.3.2/tests/ 0000775 0000000 0000000 00000000000 13305714506 0014526 5 ustar 00root root 0000000 0000000 click-log-0.3.2/tests/test_basic.py 0000664 0000000 0000000 00000005416 13305714506 0017226 0 ustar 00root root 0000000 0000000 # -*- coding: utf-8 -*-
import logging
import click
from click.testing import CliRunner
import click_log
import pytest
test_logger = logging.getLogger(__name__)
click_log.basic_config(test_logger)
test_logger.level = logging.INFO
@pytest.fixture
def runner():
return CliRunner()
def test_basic(runner):
@click.command()
def cli():
test_logger.info('hey')
test_logger.error('damn')
result = runner.invoke(cli, catch_exceptions=False)
assert not result.exception
assert result.output == 'hey\nerror: damn\n'
def test_multilines(runner):
@click.command()
def cli():
test_logger.warning("""
Lorem ipsum dolor sit amet,
consectetur adipiscing elit,
sed do eiusmod tempor incididunt""")
result = runner.invoke(cli, catch_exceptions=False)
assert not result.exception
assert result.output == (
'warning: \n'
'warning: Lorem ipsum dolor sit amet,\n'
'warning: consectetur adipiscing elit,\n'
'warning: sed do eiusmod tempor incididunt\n')
def test_unicode(runner):
@click.command()
def cli():
test_logger.error(u"""
❤️ 💔 💌 💕 💞 💓 💗 💖 💘
💝 💟 💜 💛 💚 💙""")
result = runner.invoke(cli, catch_exceptions=False)
assert not result.exception
assert result.output == (
'error: \n'
u'error: ❤️ 💔 💌 💕 💞 💓 💗 💖 💘\n'
u'error: 💝 💟 💜 💛 💚 💙\n')
def test_weird_types_log(runner):
@click.command()
def cli():
test_logger.error(42)
test_logger.error('42')
test_logger.error(b'42')
test_logger.error(u'42')
result = runner.invoke(cli, catch_exceptions=False)
assert not result.exception
assert set(result.output.splitlines()) <= set(('error: 42', 'error: b\'42\''))
def test_early_logging(runner):
i = None
def callback(context, param, value):
test_logger.debug('catch me {}!'.format(i))
@click.command()
@click_log.simple_verbosity_option(test_logger)
@click.option('--config', is_eager=True, default=None, expose_value=False,
callback=callback)
def cli():
test_logger.debug('hello')
for i in range(2):
result = runner.invoke(cli, ['-v', 'debug'], catch_exceptions=False)
assert 'debug: hello' in result.output
assert 'debug: catch me {}!'.format(i) in result.output
def test_logging_args(runner):
@click.command()
@click_log.simple_verbosity_option(test_logger)
def cli():
test_logger.debug('hello %s', 'world')
result = runner.invoke(cli, ['-v', 'debug'])
assert 'debug: hello world' in result.output
click-log-0.3.2/tox.ini 0000664 0000000 0000000 00000000154 13305714506 0014677 0 ustar 00root root 0000000 0000000 [testenv]
passenv = LANG
deps =
pytest
git+https://github.com/mitsuhiko/click
commands = py.test []