Making logs nicer since 2015!
Go to file
Gavin M. Roy 37ff1180f9 Merge pull request #10 from sprockets/tornado43-fixes
tornado_log_function: Make work with Tornado 4.3.
2015-12-11 12:59:01 -05:00
docs tornado_log_function: Make work with Tornado 4.3. 2015-12-10 09:50:48 -05:00
examples Update docs, revert tornado-app.py example, add new one 2015-06-18 09:36:51 -04:00
sprockets tornado_log_function: Make work with Tornado 4.3. 2015-12-10 09:50:48 -05:00
.gitignore SYN 2015-06-08 10:18:05 -04:00
.travis.yml Remove mock from requirements set. 2015-09-14 07:38:06 -04:00
LICENSE SYN 2015-06-08 10:18:05 -04:00
MANIFEST.in MANIFEST: Include samples in source dist. 2015-06-09 11:47:31 -04:00
README.rst README: Adjust badges slightly. 2015-06-09 09:08:40 -04:00
setup.cfg Adjust nosetests default parameters. 2015-09-14 07:33:57 -04:00
setup.py Switch from py_module to sub-package. 2015-10-02 07:27:13 -04:00
tests.py Add ContextFilter tests. 2015-09-14 07:32:59 -04:00
tox.ini Remove mock from requirements set. 2015-09-14 07:38:06 -04:00

README.rst

sprockets.logging
=================
Making logs nicer since 2015!

|Version| |Downloads| |Travis| |CodeCov| |ReadTheDocs|

Installation
------------
``sprockets.logging`` is available on the
`Python Package Index <https://pypi.python.org/pypi/sprockets.logging>`_
and can be installed via ``pip`` or ``easy_install``:

.. code-block:: bash

   pip install sprockets.logging

Documentation
-------------
https://sprocketslogging.readthedocs.org

Requirements
------------
-  No external requirements

Example
-------
This examples demonstrates the most basic usage of ``sprockets.logging``

.. code-block:: python

   import logging
   import sys

   import sprockets.logging


   formatter = logging.Formatter('%(levelname)s %(message)s {%(context)s}')
   handler = logging.StreamHandler(sys.stdout)
   handler.setFormatter(formatter)
   handler.addFilter(sprockets.logging.ContextFilter(properties=['context']))
   logging.Logger.root.addHandler(handler)
   logging.Logger.root.setLevel(logging.DEBUG)

   # Outputs: INFO Hi there {None}
   logging.info('Hi there')

   # Outputs: INFO No KeyError {bah}
   logging.info('No KeyError', extra={'context': 'bah'})

   # Outputs: INFO Now with context! {foo}
   adapted = logging.LoggerAdapter(logging.Logger.root, extra={'context': 'foo'})
   adapted.info('Now with context!')

Source
------
``sprockets.logging`` source is available on Github at `https://github.com/sprockets/sprockets.logging <https://github.com/sprockets/sprockets.logging>`_

License
-------
``sprockets.logging`` is released under the `3-Clause BSD license <https://github.com/sprockets/sprockets.logging/blob/master/LICENSE>`_.


.. |Version| image:: https://badge.fury.io/py/sprockets.logging.svg?
   :target: http://badge.fury.io/py/sprockets.logging

.. |Travis| image:: https://travis-ci.org/sprockets/sprockets.logging.svg?branch=master
   :target: https://travis-ci.org/sprockets/sprockets.logging

.. |CodeCov| image:: http://codecov.io/github/sprockets/sprockets.logging/coverage.svg?branch=master
   :target: https://codecov.io/github/sprockets/sprockets.logging?branch=master

.. |Downloads| image:: https://pypip.in/d/sprockets.logging/badge.svg?
   :target: https://pypi.python.org/pypi/sprockets.logging

.. |ReadTheDocs| image:: https://readthedocs.org/projects/sprocketslogging/badge/
   :target: https://sprocketslogging.readthedocs.org