Metadata-Version: 2.0
Name: django-logutils
Version: 0.2.5
Summary: Various logging-related utilities for Django projects.
Home-page: https://github.com/jsmits/django-logutils
Author: Sander Smits
Author-email: jhmsmits@gmail.com
License: BSD
Keywords: django-logutils
Platform: UNKNOWN
Classifier: Development Status :: 3 - Alpha
Classifier: Framework :: Django
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: BSD License
Classifier: Natural Language :: English
Classifier: Programming Language :: Python :: 2
Classifier: Programming Language :: Python :: 2.6
Classifier: Programming Language :: Python :: 2.7
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.3
Classifier: Programming Language :: Python :: 3.4
Requires-Dist: django
Requires-Dist: django-appconf

=============================
django-logutils
=============================

.. image:: https://badge.fury.io/py/django-logutils.png
    :target: https://badge.fury.io/py/django-logutils

.. image:: https://travis-ci.org/jsmits/django-logutils.png?branch=master
    :target: https://travis-ci.org/jsmits/django-logutils

Various logging-related utilities for Django projects. For now, it provides
a LoggingMiddleware class.

Quickstart
----------

Install django-logutils::

    pip install django-logutils

LoggingMiddleware
-----------------

LoggingMiddleware is middleware class for Django, that logs extra
request-related information. To use it in your Django projects, add it to
your `MIDDLEWARE_CLASSES` setting::

    MIDDLEWARE_CLASSES = (
        ...
        'django_logutils.middleware.LoggingMiddleware',
        ...
    )

The extra information consists of:

- event (default: 'request', can be overridden by using the
  LOGUTILS_LOGGING_MIDDLEWARE_EVENT setting in your project

- remote ip address: the remote ip address of the user doing the request.

- user email: the email address of the requesting user, if available

- request method: post or get

- request url path

- response status code

- content length of the response body

- request time

The log message itself is a string composed of the remote ip address, the user
email, the request method, the request url, the status code, the content
length of the body and the request time. Additionally, a dictionary with the
log items are added as a extra keyword argument when sending a logging
statement.

If settings.DEBUG is True or the request time is more than 1 second, two
 additional parameters are added to the logging dictionary: `nr_queries` that
 represents the number of queries executed during the request-response cycle
 and `sql_time` that represents the time it took to execute those queries.

Development
-----------

Install the test requirements::

    $ pip install -r requirements/test.txt

Run the tests to check everything is fine::

    $ make test

To run the tests and opening the coverage html in your browser::

    $ make coverage

To run flake8 and pylint, do::

    $ make lint

To generate the documentation, do::

    $ make docs




History
-------

0.2.5 (2015-07-31)
++++++++++++++++++

- Reach 100% test coverage.


0.2.4 (2015-07-31)
++++++++++++++++++

- Improve project structure. 


0.2.3 (2015-07-30)
++++++++++++++++++

- Add `log_event` utility function for logging events. 


0.2.2 (2015-07-29)
++++++++++++++++++

- Add `add_items_to_message` utility function.


0.2.1 (2015-07-29)
++++++++++++++++++

- More and better tests. 


0.2.0 (2015-07-28)
++++++++++++++++++

- Release replacing previous faulty dev release.


0.1.0 (2015-07-28)
++++++++++++++++++

* First release on PyPI.


