Skip to main content

JSON Logging Library with Python

Project description

Project JSONkLog

The goal of this library is to provide a simple formatter, and handlers for standard python logging libraries to deal with JSON output in a sort of “set it and forget it” methodology that python logging currently provides.

Formatters :

Currently there are two formatters:

  • JSONFormatter

  • JSONFormatterSimple

Each of the formatters processes the standard python logging messages into JSON however the “Simple” library provides a limited output including only 3 key elements and the mysterious 4th element “Extras”

Please note that “extras” as a dictionary requires the content to be nested under the “extra” key within the dictionary

For examples, please see example_formatter.py within the source tree at:

Handlers :

Currently there are two handlers, which require JSONFormatter, or JSONFormatterSimple to have been used :

  • MongoDBHandler

  • ElasticSearchHandler

Each of the handlers can process the standard JSON messages from the included JSON formatting libraries, and can have different destinations specified as follows:

MongoDBHandler :

This handler speaks MongoDB (using ‘pymongo’), and can take the following arguments:

  • host - The destination host / ip of the MongoDB server

  • port - The destination port of the MongoDB server

  • db - The destination database to send messages to

  • collection - The destination collection to send messages to

ElasticSearchHandler :

This handler speaks ElasticSearch (using ‘requests’), and can take the following arguments:

  • host - The destination host / ip of the ElasticSearch server

  • port - The destination port of the ElasticSearch server

  • index - The destination index to send messages to

  • doc_type - The destination doc_type to send messages to

Note :

To format your JSON into “human readable whatsits” ensure your handler outputs to stdout, and then pipe through the node-json library (‘json’), installed as per:

  • npm install -g json

This is not a requirement, but rather what I’m using to do my testing ;)

History

0.15.0 (2012-06-25)

  • Added additional examples, and moved them to /examples

  • Added more documentation

  • Reformatted handlers to make them easier to work with

  • Made handlers depend on json formatters

0.10.0 (2012-06-19)

  • Initial release of MongoDBHandler, and ElasticSearchHandler

  • Initial documentation around Handlers.

  • Example code added for handler.py

0.05.0 (2012-06-14)

  • Initial release of JSONFormatter, and JSONFormatterSimple

  • Initial documentation added

  • Example code added for formatter.py

0.01.0 (2012-06-10)

  • Initial release

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

jsonklog-0.15.0.tar.gz (8.4 kB view details)

Uploaded Source

File details

Details for the file jsonklog-0.15.0.tar.gz.

File metadata

  • Download URL: jsonklog-0.15.0.tar.gz
  • Upload date:
  • Size: 8.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for jsonklog-0.15.0.tar.gz
Algorithm Hash digest
SHA256 86eaaac485663c4c99f02cac6a173df5b1174e1cefd7d6d71c1617591afed86d
MD5 9a9632a1d897ebab52327cf47bd3cba6
BLAKE2b-256 83c68456795bbf9c5ba830b55de0755c19a5f8814966dc33d429f504961b7fc4

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page