From da284e7e07d9da86eb17e17cad1dee8f983645f6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fl=C3=A1vio=20Pontes?= Date: Mon, 11 Sep 2017 16:33:49 -0300 Subject: [PATCH] Added rst version of README for PyPI and bumped version number. --- .travis.yml | 2 + README.rst | 53 +++++++++++++++++++++++++++ setup.cfg | 2 + setup.py | 13 +++++-- simple_json_log_formatter/__init__.py | 2 +- 5 files changed, 68 insertions(+), 4 deletions(-) create mode 100644 README.rst create mode 100644 setup.cfg diff --git a/.travis.yml b/.travis.yml index ff35b20..8750679 100644 --- a/.travis.yml +++ b/.travis.yml @@ -5,6 +5,8 @@ python: - '3.6' - nightly - pypy3 +before_install: + - pip install --user codecov install: pip install .[dev] script: coverage run setup.py test after_success: diff --git a/README.rst b/README.rst new file mode 100644 index 0000000..6f788b0 --- /dev/null +++ b/README.rst @@ -0,0 +1,53 @@ +Simple Json Logging Formatter +============================= + +|Build Status| |codecov| + +This is a fork of ``simple_json_logger``, extracting the formatter into +it's own project. + +It formats the Python logging.Record into a JSON suitable for indexing +engines like Logstash and AWS CloudWatch Logs. + +Installation +------------ + +``pip install simple_json_logging_formatter`` + +Usage +----- + +Simply set the formatter in a log handler and add it to the current +logger. + +For example, to print the JSON logs to the current stream, set up the +logger with the following: + +.. code:: python + + import json, logging + from simple_json_log_formatter import SimpleJsonFormatter + handler = logging.StreamHandler() + handler.setFormatter(SimpleJsonFormatter(json.dumps)) + logging.getLogger().addHandler(handler) + logging.getLogger().setLevel(logging.INFO) + +And then simply call ``logging.info('TEST')``. It should print something +like this: + +``{"timestamp": "2017-09-08T17:01:26.408975", "line_number": 1, "function": "", "module": "", "level": "INFO", "path": "", "msg": "TEST"}`` + +Testing +------- + +``python setup.py test`` + +Compatibility +------------- + +Python versions 3.4+ are supported. + +.. |Build Status| image:: https://travis-ci.org/flaviocpontes/simple_json_log_formatter.svg?branch=master + :target: https://travis-ci.org/flaviocpontes/simple_json_log_formatter +.. |codecov| image:: https://codecov.io/gh/flaviocpontes/simple_json_log_formatter/branch/master/graph/badge.svg + :target: https://codecov.io/gh/flaviocpontes/simple_json_log_formatter diff --git a/setup.cfg b/setup.cfg new file mode 100644 index 0000000..224a779 --- /dev/null +++ b/setup.cfg @@ -0,0 +1,2 @@ +[metadata] +description-file = README.md \ No newline at end of file diff --git a/setup.py b/setup.py index 49cafbb..d4ec5df 100644 --- a/setup.py +++ b/setup.py @@ -1,23 +1,30 @@ +from os import path from setuptools import setup, find_packages from simple_json_log_formatter import __version__, __author__,\ __author_email__ +here = path.abspath(path.dirname(__file__)) +with open(path.join(here, 'README.rst')) as f: + long_description = f.read() + setup( name='simple_json_log_formatter', license='MIT', version=__version__, + description='Simple log formatter for Logstash-compatible JSON output', + long_description=long_description, packages=find_packages(exclude=['tests']), + package_data={'': ['README.rst', ]}, url='https://github.com/flaviocpontes/simple_json_log_formatter', - download_url='https://github.com/flaviocpontes/simple_json_log_formatter/archive/0.4.0.tar.gz', + download_url='https://github.com/flaviocpontes/simple_json_log_formatter/archive/0.4.2.tar.gz', author=__author__, author_email=__author_email__, python_requires='>=3.4', keywords='logging json log output formatter', classifiers=[ - 'Development Status :: 5 - Stable', + 'Development Status :: 5 - Production/Stable', 'Intended Audience :: Developers', 'License :: OSI Approved :: MIT License', - 'Programming Language :: Python :: 3.3', 'Programming Language :: Python :: 3.4', 'Programming Language :: Python :: 3.5', 'Programming Language :: Python :: 3.6' diff --git a/simple_json_log_formatter/__init__.py b/simple_json_log_formatter/__init__.py index ded5787..3f0cc5b 100644 --- a/simple_json_log_formatter/__init__.py +++ b/simple_json_log_formatter/__init__.py @@ -1,6 +1,6 @@ from .formatter import SimpleJsonFormatter -__version_info__ = (0, 4, 1) +__version_info__ = (0, 4, 2) __version__ = '.'.join(map(str, __version_info__)) __title__ = 'Simple JSON Log Formatter'