Skip to content

Commit

Permalink
Merge pull request #8 from sprockets/fix-query-arg-handling
Browse files Browse the repository at this point in the history
Fix query arg handling
  • Loading branch information
amberheilman committed Sep 17, 2015
2 parents 16a57b6 + 22e3023 commit 523ec0b
Show file tree
Hide file tree
Showing 9 changed files with 181 additions and 159 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Expand Up @@ -4,7 +4,7 @@ python:
- pypy
- 3.4
before_install:
- pip install nose coverage codecov mock tornado
- pip install nose coverage codecov tornado
install:
- pip install -e .
script: nosetests
Expand Down
4 changes: 2 additions & 2 deletions docs/examples.rst
Expand Up @@ -23,10 +23,10 @@ Tornado Application JSON Logging
--------------------------------
If you're looking to log Tornado requests as JSON, the
:class:`sprockets.logging.JSONRequestFormatter` class works in conjunction with
the :method:`tornado_log_function` method to output all Tornado log entries as
the :func:`tornado_log_function` method to output all Tornado log entries as
JSON objects. In the following example, the dictionary-based configuration is
expanded upon to include specify the :class:`sprockets.logging.JSONRequestFormatter`
as the formatter and passes :method:`tornado_log_function` in as the ``log_function``
as the formatter and passes :func:`tornado_log_function` in as the ``log_function``
when creating the Tornado application.

.. literalinclude:: ../examples/tornado-json-logger.py
15 changes: 12 additions & 3 deletions docs/history.rst
@@ -1,6 +1,10 @@
Version History
===============

`1.3.1`_ Sep 14, 2015
---------------------
- Fix query_arguments handling in Python 3

`1.3.0`_ Aug 28, 2015
---------------------
- Add the traceback and environment if set
Expand All @@ -17,19 +21,24 @@ Version History
`1.1.0`_ Jun 18, 2015
---------------------
- Added :class:`sprockets.logging.JSONRequestFormatter`
- Added :method:`sprockets.logging.tornado_log_function`
- Added :func:`sprockets.logging.tornado_log_function`
- Added convenience constants and methods as a pass through to Python's logging package:

- :data:`sprockets.logging.DEBUG` to :data:`logging.DEBUG`
- :data:`sprockets.logging.ERROR` to :data:`logging.ERROR`
- :data:`sprockets.logging.INFO` to :data:`logging.INFO`
- :data:`sprockets.logging.WARN` to :data:`logging.WARN`
- :data:`sprockets.logging.WARNING` to :data:`logging.WARNING`
- :method:`sprockets.logging.dictConfig` to :method:`logging.config.dictConfig`
- :method:`sprockets.logging.getLogger` to :method:`logging.getLogger`
- :func:`sprockets.logging.dictConfig` to :func:`logging.config.dictConfig`
- :func:`sprockets.logging.getLogger` to :func:`logging.getLogger`

`1.0.0`_ Jun 09, 2015
---------------------
- Added :class:`sprockets.logging.ContextFilter`

.. _1.3.1: https://github.com/sprockets/sprockets.logging/compare/1.3.0...1.3.1
.. _1.3.0: https://github.com/sprockets/sprockets.logging/compare/1.2.1...1.3.0
.. _1.2.1: https://github.com/sprockets/sprockets.logging/compare/1.2.0...1.2.1
.. _1.2.0: https://github.com/sprockets/sprockets.logging/compare/1.1.0...1.2.0
.. _1.1.0: https://github.com/sprockets/sprockets.logging/compare/1.0.0...1.1.0
.. _1.0.0: https://github.com/sprockets/sprockets.logging/compare/0.0.0...1.0.0
11 changes: 1 addition & 10 deletions docs/index.rst
@@ -1,22 +1,13 @@
.. include:: ../README.rst

API Documentation
-----------------
.. toctree::
:maxdepth: 2
:hidden:

api
examples
history

Version History
---------------
See :doc:`history`

Issues
------
Please report any issues to the Github project at `https://github.com/sprockets/sprockets.logging/issues <https://github.com/sprockets/sprockets.logging/issues>`_

Indices and tables
------------------

Expand Down
2 changes: 1 addition & 1 deletion setup.cfg
Expand Up @@ -2,6 +2,6 @@
universal = 1

[nosetests]
with-coverage = 1
cover-branches = 1
cover-erase = 1
cover-package = sprockets.logging
3 changes: 0 additions & 3 deletions setup.py
Expand Up @@ -11,9 +11,6 @@
setup_requires = []
tests_require = ['nose>=1.3,<2', 'tornado>3,<5']

if sys.version_info < (3, 0):
tests_require.append('mock')

setuptools.setup(
name='sprockets.logging',
version=sprockets.logging.__version__,
Expand Down
10 changes: 6 additions & 4 deletions sprockets/logging.py
Expand Up @@ -18,11 +18,12 @@
import traceback

try:
from tornado import log
except ImportError:
from tornado import escape, log
except ImportError: # pragma no cover
escape = None
log = None

version_info = (1, 3, 0)
version_info = (1, 3, 1)
__version__ = '.'.join(str(v) for v in version_info)

# Shortcut methods and constants to avoid needing to import logging directly
Expand Down Expand Up @@ -148,7 +149,8 @@ def tornado_log_function(handler):
'method': handler.request.method,
'path': handler.request.path,
'protocol': handler.request.protocol,
'query_args': handler.request.query_arguments,
'query_args': escape.recursive_unicode(
handler.request.query_arguments),
'remote_ip': handler.request.remote_ip,
'status_code': status_code,
'environment': os.environ.get('ENVIRONMENT')})
Expand Down

0 comments on commit 523ec0b

Please sign in to comment.