forked from diogommartins/simple_json_logger
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added rst version of README for PyPI and bumped version number.
- Loading branch information
Flávio Pontes
committed
Sep 11, 2017
1 parent
7f250a2
commit da284e7
Showing
5 changed files
with
68 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
[metadata] | ||
description-file = README.md |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters