mirror of
https://github.com/sprockets/sprockets.logging.git
synced 2024-11-21 11:18:35 +00:00
SYN
This commit is contained in:
commit
6b04a86fda
19 changed files with 364 additions and 0 deletions
57
.gitignore
vendored
Normal file
57
.gitignore
vendored
Normal file
|
@ -0,0 +1,57 @@
|
|||
# Editor
|
||||
*.swp
|
||||
*.swo
|
||||
|
||||
# Byte-compiled / optimized / DLL files
|
||||
__pycache__/
|
||||
*.py[cod]
|
||||
|
||||
# C extensions
|
||||
*.so
|
||||
|
||||
# Distribution / packaging
|
||||
.Python
|
||||
env/
|
||||
bin/
|
||||
build/
|
||||
develop-eggs/
|
||||
dist/
|
||||
eggs/
|
||||
lib/
|
||||
lib64/
|
||||
parts/
|
||||
sdist/
|
||||
var/
|
||||
*.egg-info/
|
||||
.installed.cfg
|
||||
*.egg
|
||||
|
||||
# Installer logs
|
||||
pip-log.txt
|
||||
pip-delete-this-directory.txt
|
||||
|
||||
# Unit test / coverage reports
|
||||
htmlcov/
|
||||
.tox/
|
||||
.coverage
|
||||
.cache
|
||||
nosetests.xml
|
||||
coverage.xml
|
||||
|
||||
# Translations
|
||||
*.mo
|
||||
|
||||
# Mr Developer
|
||||
.mr.developer.cfg
|
||||
.project
|
||||
.pydevproject
|
||||
|
||||
# Rope
|
||||
.ropeproject
|
||||
|
||||
# Django stuff:
|
||||
*.log
|
||||
*.pot
|
||||
|
||||
# Sphinx documentation
|
||||
docs/_build/
|
15
.travis.yml
Normal file
15
.travis.yml
Normal file
|
@ -0,0 +1,15 @@
|
|||
%YAML 1.1
|
||||
---
|
||||
language: python
|
||||
python:
|
||||
- 2.7
|
||||
- pypy
|
||||
- 3.4
|
||||
before_install:
|
||||
- pip install codecov
|
||||
install:
|
||||
- pip install -r test-requirements.txt
|
||||
- pip install -e .
|
||||
script: nosetests
|
||||
after_success:
|
||||
- codecov
|
25
LICENSE
Normal file
25
LICENSE
Normal file
|
@ -0,0 +1,25 @@
|
|||
Copyright (c) 2015 AWeber Communications
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without modification,
|
||||
are permitted provided that the following conditions are met:
|
||||
|
||||
* Redistributions of source code must retain the above copyright notice, this
|
||||
list of conditions and the following disclaimer.
|
||||
* Redistributions in binary form must reproduce the above copyright notice,
|
||||
this list of conditions and the following disclaimer in the documentation
|
||||
and/or other materials provided with the distribution.
|
||||
* Neither the name of Sprockets nor the names of its
|
||||
contributors may be used to endorse or promote products derived from this
|
||||
software without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
|
||||
INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
||||
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
|
||||
OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
8
MANIFEST.in
Normal file
8
MANIFEST.in
Normal file
|
@ -0,0 +1,8 @@
|
|||
include LICENSE
|
||||
include README.rst
|
||||
include HISTORY.rst
|
||||
include *requirements.txt
|
||||
include tests.py
|
||||
graft docs
|
||||
global-exclude __pycache__
|
||||
global-exclude *.pyc
|
74
README.rst
Normal file
74
README.rst
Normal file
|
@ -0,0 +1,74 @@
|
|||
sprockets.logging
|
||||
=================
|
||||
Making logs nicer since 2015!
|
||||
|
||||
|Version| |Downloads| |Status| |Coverage| |License|
|
||||
|
||||
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 how to use ``sprockets.logging`` by ...
|
||||
|
||||
.. 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)
|
||||
|
||||
# Outputs: INFO Hi there {}
|
||||
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'})
|
||||
adapter.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
|
||||
|
||||
.. |Status| image:: https://travis-ci.org/sprockets/sprockets.logging.svg?branch=master
|
||||
:target: https://travis-ci.org/sprockets/sprockets.logging
|
||||
|
||||
.. |Coverage| 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
|
||||
|
||||
.. |License| image:: https://pypip.in/license/sprockets.logging/badge.svg?
|
||||
:target: https://sprocketslogging.readthedocs.org
|
6
dev-requirements.txt
Normal file
6
dev-requirements.txt
Normal file
|
@ -0,0 +1,6 @@
|
|||
-r requirements.txt
|
||||
-r test-requirements.txt
|
||||
flake8>=2.1,<3
|
||||
sphinx>=1.2,<2
|
||||
sphinx-rtd-theme>=0.1,<1.0
|
||||
sphinxcontrib-httpdomain>=1.2,<2
|
4
docs/api.rst
Normal file
4
docs/api.rst
Normal file
|
@ -0,0 +1,4 @@
|
|||
API Reference
|
||||
=============
|
||||
.. automodule:: sprockets.logging
|
||||
:members:
|
28
docs/conf.py
Normal file
28
docs/conf.py
Normal file
|
@ -0,0 +1,28 @@
|
|||
#!/usr/bin/env python
|
||||
import sphinx_rtd_theme
|
||||
|
||||
from sprockets.logging import version_info, __version__
|
||||
|
||||
needs_sphinx = '1.0'
|
||||
extensions = [
|
||||
'sphinx.ext.autodoc',
|
||||
'sphinx.ext.intersphinx',
|
||||
'sphinxcontrib.httpdomain',
|
||||
]
|
||||
templates_path = []
|
||||
source_suffix = '.rst'
|
||||
master_doc = 'index'
|
||||
project = 'sprockets.logging'
|
||||
copyright = '2015, Dave Shawley'
|
||||
version = '.'.join(__version__.split('.')[0:1])
|
||||
release = __version__
|
||||
if len(version_info) > 3:
|
||||
release += '-{0}'.format(str(v) for v in version_info[3:])
|
||||
exclude_patterns = []
|
||||
pygments_style = 'sphinx'
|
||||
html_theme = 'sphinx_rtd_theme'
|
||||
html_theme_path = [sphinx_rtd_theme.get_html_theme_path()]
|
||||
intersphinx_mapping = {
|
||||
'python': ('https://docs.python.org/', None),
|
||||
'sprockets': ('https://sprockets.readthedocs.org/en/latest/', None),
|
||||
}
|
31
docs/examples.rst
Normal file
31
docs/examples.rst
Normal file
|
@ -0,0 +1,31 @@
|
|||
Examples
|
||||
========
|
||||
|
||||
Simple Usage
|
||||
------------
|
||||
The following snippet uses :class:`sprockets.logging.filters.ContextFilter`
|
||||
to insert context information into a message using a
|
||||
:class:`logging.LoggerAdapter` instance.
|
||||
|
||||
.. 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)
|
||||
|
||||
# Outputs: INFO Hi there {}
|
||||
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'})
|
||||
adapter.info('Now with context!')
|
6
docs/history.rst
Normal file
6
docs/history.rst
Normal file
|
@ -0,0 +1,6 @@
|
|||
Version History
|
||||
===============
|
||||
|
||||
Next Release
|
||||
------------
|
||||
- implement greatness
|
25
docs/index.rst
Normal file
25
docs/index.rst
Normal file
|
@ -0,0 +1,25 @@
|
|||
.. include:: ../README.rst
|
||||
|
||||
API Documentation
|
||||
-----------------
|
||||
.. toctree::
|
||||
:maxdepth: 2
|
||||
|
||||
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
|
||||
------------------
|
||||
|
||||
* :ref:`genindex`
|
||||
* :ref:`modindex`
|
||||
* :ref:`search`
|
0
requirements.txt
Normal file
0
requirements.txt
Normal file
7
setup.cfg
Normal file
7
setup.cfg
Normal file
|
@ -0,0 +1,7 @@
|
|||
[bdist_wheel]
|
||||
universal = 1
|
||||
|
||||
[nosetests]
|
||||
with-coverage = 1
|
||||
cover-erase = 1
|
||||
cover-package = sprockets.logging
|
61
setup.py
Executable file
61
setup.py
Executable file
|
@ -0,0 +1,61 @@
|
|||
#!/usr/bin/env python
|
||||
import codecs
|
||||
import sys
|
||||
|
||||
import setuptools
|
||||
|
||||
import sprockets.logging
|
||||
|
||||
|
||||
def read_requirements_file(req_name):
|
||||
requirements = []
|
||||
try:
|
||||
with codecs.open(req_name, encoding='utf-8') as req_file:
|
||||
for req_line in req_file:
|
||||
if '#' in req_line:
|
||||
req_line = req_line[0:req_line.find('#')].strip()
|
||||
if req_line:
|
||||
requirements.append(req_line.strip())
|
||||
except IOError:
|
||||
pass
|
||||
return requirements
|
||||
|
||||
|
||||
install_requires = read_requirements_file('requirements.txt')
|
||||
setup_requires = read_requirements_file('setup-requirements.txt')
|
||||
tests_require = read_requirements_file('test-requirements.txt')
|
||||
|
||||
if sys.version_info < (3, 0):
|
||||
tests_require.append('mock')
|
||||
|
||||
setuptools.setup(
|
||||
name='sprockets.logging',
|
||||
version=sprockets.logging.__version__,
|
||||
description='Making logs nicer since 2015!',
|
||||
long_description=codecs.open('README.rst', encoding='utf-8').read(),
|
||||
url='https://github.com/sprockets/sprockets.logging.git',
|
||||
author='Dave Shawley',
|
||||
author_email='daves@aweber.com',
|
||||
license='BSD',
|
||||
classifiers=[
|
||||
'Development Status :: 4 - Beta',
|
||||
'Intended Audience :: Developers',
|
||||
'License :: OSI Approved :: BSD License',
|
||||
'Natural Language :: English',
|
||||
'Operating System :: OS Independent',
|
||||
'Programming Language :: Python :: 2',
|
||||
'Programming Language :: Python :: 2.7',
|
||||
'Programming Language :: Python :: 3',
|
||||
'Programming Language :: Python :: 3.4',
|
||||
'Programming Language :: Python :: Implementation :: CPython',
|
||||
'Programming Language :: Python :: Implementation :: PyPy',
|
||||
'Topic :: Software Development :: Libraries',
|
||||
'Topic :: Software Development :: Libraries :: Python Modules'
|
||||
],
|
||||
namespace_packages=['sprockets'],
|
||||
py_modules=['sprockets.logging'],
|
||||
install_requires=install_requires,
|
||||
setup_requires=setup_requires,
|
||||
tests_require=tests_require,
|
||||
test_suite='nose.collector',
|
||||
zip_safe=True)
|
1
sprockets/__init__.py
Normal file
1
sprockets/__init__.py
Normal file
|
@ -0,0 +1 @@
|
|||
__import__('pkg_resources').declare_namespace(__name__)
|
5
sprockets/logging.py
Normal file
5
sprockets/logging.py
Normal file
|
@ -0,0 +1,5 @@
|
|||
"""
|
||||
Make good log output easier.
|
||||
"""
|
||||
version_info = (0, 0, 0)
|
||||
__version__ = '.'.join(str(v) for v in version_info)
|
2
test-requirements.txt
Normal file
2
test-requirements.txt
Normal file
|
@ -0,0 +1,2 @@
|
|||
coverage>=3.7,<4
|
||||
nose>=1.3,<2
|
0
tests.py
Normal file
0
tests.py
Normal file
9
tox.ini
Normal file
9
tox.ini
Normal file
|
@ -0,0 +1,9 @@
|
|||
[tox]
|
||||
envlist = py27,py34
|
||||
indexserver =
|
||||
default = https://pypi.python.org/simple
|
||||
toxworkdir = build/tox
|
||||
|
||||
[testenv]
|
||||
commands = nosetests []
|
||||
deps = -rtest-requirements.txt
|
Loading…
Reference in a new issue