Skip to content

Commit

Permalink
Added rst version of README for PyPI and bumped version number.
Browse files Browse the repository at this point in the history
  • Loading branch information
Flávio Pontes committed Sep 11, 2017
1 parent 7f250a2 commit da284e7
Show file tree
Hide file tree
Showing 5 changed files with 68 additions and 4 deletions.
2 changes: 2 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
53 changes: 53 additions & 0 deletions README.rst
Original file line number Diff line number Diff line change
@@ -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>", "module": "<input>", "level": "INFO", "path": "<input>", "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
2 changes: 2 additions & 0 deletions setup.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[metadata]
description-file = README.md
13 changes: 10 additions & 3 deletions setup.py
Original file line number Diff line number Diff line change
@@ -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'
Expand Down
2 changes: 1 addition & 1 deletion simple_json_log_formatter/__init__.py
Original file line number Diff line number Diff line change
@@ -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'
Expand Down

0 comments on commit da284e7

Please sign in to comment.