summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVinay Sajip <vinay_sajip@yahoo.co.uk>2017-02-20 17:41:03 +0000
committerVinay Sajip <vinay_sajip@yahoo.co.uk>2017-02-20 17:41:03 +0000
commit415a394eb5a17fcb5c2ad39629ce4e5674c99b01 (patch)
treed35175afc75beb033fbb2c2a2f9b016b79e40e3b
parent6ef0b4dce43399bd2f9e07a3d0070286a806c10d (diff)
downloadlogutils-git-415a394eb5a17fcb5c2ad39629ce4e5674c99b01.tar.gz
Changes for 0.3.4.
-rw-r--r--.hgignore4
-rw-r--r--.travis.yml17
-rw-r--r--LICENSE.txt2
-rw-r--r--README.txt2
-rw-r--r--doc/conf.py4
-rw-r--r--logutils/__init__.py11
-rw-r--r--logutils/adapter.py3
-rw-r--r--logutils/colorize.py5
-rw-r--r--logutils/dictconfig.py2
-rw-r--r--logutils/http.py5
-rw-r--r--logutils/queue.py17
-rw-r--r--logutils/redis.py11
-rw-r--r--logutils/testing.py19
-rw-r--r--setup.py6
-rw-r--r--tests/logutil_tests.py2
-rw-r--r--tests/mytest.py2
-rw-r--r--tests/test_adapter.py3
-rw-r--r--tests/test_colorize.py3
-rw-r--r--tests/test_dictconfig.py3
-rw-r--r--tests/test_formatter.py4
-rw-r--r--tests/test_messages.py4
-rw-r--r--tests/test_queue.py3
-rw-r--r--tests/test_redis.py5
-rw-r--r--tests/test_testing.py3
24 files changed, 69 insertions, 71 deletions
diff --git a/.hgignore b/.hgignore
index b29ad6c..20d0b42 100644
--- a/.hgignore
+++ b/.hgignore
@@ -1,4 +1,4 @@
\.py[co]
-build
-dist
+(build|dist)/
+.coverage$
diff --git a/.travis.yml b/.travis.yml
new file mode 100644
index 0000000..d88b797
--- /dev/null
+++ b/.travis.yml
@@ -0,0 +1,17 @@
+language: python
+sudo: false
+python:
+ - "2.6"
+ - "2.7"
+# - "3.2" removed because Coveralls/coverage 4.0 fails on 3.2
+ - "3.3"
+ - "3.4"
+ - "3.5"
+ - "3.6"
+ - "pypy"
+install:
+ - pip install coveralls
+script:
+ - "python setup.py test"
+ - "coverage run setup.py test"
+after_success: coveralls
diff --git a/LICENSE.txt b/LICENSE.txt
index 292324b..b633581 100644
--- a/LICENSE.txt
+++ b/LICENSE.txt
@@ -1,4 +1,4 @@
-Copyright (c) 2008-2013 by Vinay Sajip.
+Copyright (c) 2008-2017 by Vinay Sajip.
All rights reserved.
Redistribution and use in source and binary forms, with or without
diff --git a/README.txt b/README.txt
index 6c26fb2..a60fbaf 100644
--- a/README.txt
+++ b/README.txt
@@ -1,4 +1,4 @@
-logutils 0.3.3
+logutils 0.3.4
==============
The logutils package provides a set of handlers for the Python standard
library's logging package.
diff --git a/doc/conf.py b/doc/conf.py
index cd092a9..ebb2928 100644
--- a/doc/conf.py
+++ b/doc/conf.py
@@ -42,7 +42,7 @@ master_doc = 'index'
# General information about the project.
project = u'Logutils'
-copyright = u'2010-2013, Vinay Sajip'
+copyright = u'2010-2017, Vinay Sajip'
# The version info for the project you're documenting, acts as replacement for
# |version| and |release|, also used in various other places throughout the
@@ -51,7 +51,7 @@ copyright = u'2010-2013, Vinay Sajip'
# The short X.Y version.
version = '0.3'
# The full version, including alpha/beta/rc tags.
-release = '0.3.3'
+release = '0.3.4'
# The language for content autogenerated by Sphinx. Refer to documentation
# for a list of supported languages.
diff --git a/logutils/__init__.py b/logutils/__init__.py
index 44e261f..89b02f0 100644
--- a/logutils/__init__.py
+++ b/logutils/__init__.py
@@ -1,5 +1,5 @@
#
-# Copyright (C) 2010-2013 Vinay Sajip. See LICENSE.txt for details.
+# Copyright (C) 2010-2017 Vinay Sajip. See LICENSE.txt for details.
#
"""
The logutils package provides a set of handlers for the Python standard
@@ -13,7 +13,7 @@ of Python, and so are packaged here.
import logging
from string import Template
-__version__ = '0.3.3'
+__version__ = '0.3.4'
class NullHandler(logging.Handler):
"""
@@ -29,7 +29,7 @@ class NullHandler(logging.Handler):
def handle(self, record):
"""
Handle a record. Does nothing in this class, but in other
- handlers it typically filters and then emits the record in a
+ handlers it typically filters and then emits the record in a
thread-safe way.
"""
pass
@@ -160,7 +160,7 @@ class BraceMessage(object):
self.args = args
self.kwargs = kwargs
self.str = None
-
+
def __str__(self):
if self.str is None:
self.str = self.fmt.format(*self.args, **self.kwargs)
@@ -171,7 +171,7 @@ class DollarMessage(object):
self.fmt = fmt
self.kwargs = kwargs
self.str = None
-
+
def __str__(self):
if self.str is None:
self.str = Template(self.fmt).substitute(**self.kwargs)
@@ -192,4 +192,3 @@ def hasHandlers(logger):
else:
logger = logger.parent
return rv
-
diff --git a/logutils/adapter.py b/logutils/adapter.py
index 399e1ee..92706c0 100644
--- a/logutils/adapter.py
+++ b/logutils/adapter.py
@@ -1,5 +1,5 @@
#
-# Copyright (C) 2010-2013 Vinay Sajip. See LICENSE.txt for details.
+# Copyright (C) 2010-2017 Vinay Sajip. See LICENSE.txt for details.
#
import logging
import logutils
@@ -113,4 +113,3 @@ class LoggerAdapter(object):
See if the underlying logger has any handlers.
"""
return logutils.hasHandlers(self.logger)
-
diff --git a/logutils/colorize.py b/logutils/colorize.py
index 2c39639..f95c036 100644
--- a/logutils/colorize.py
+++ b/logutils/colorize.py
@@ -1,5 +1,5 @@
#
-# Copyright (C) 2010-2013 Vinay Sajip. All rights reserved.
+# Copyright (C) 2010-2017 Vinay Sajip. All rights reserved.
#
import ctypes
import logging
@@ -18,7 +18,7 @@ class ColorizingStreamHandler(logging.StreamHandler):
:param strm: The stream to colorize - typically ``sys.stdout``
or ``sys.stderr``.
"""
-
+
# color names to indices
color_map = {
'black': 0,
@@ -191,4 +191,3 @@ class ColorizingStreamHandler(logging.StreamHandler):
parts[0] = self.colorize(parts[0], record)
message = '\n'.join(parts)
return message
-
diff --git a/logutils/dictconfig.py b/logutils/dictconfig.py
index 5f6c0ad..c774552 100644
--- a/logutils/dictconfig.py
+++ b/logutils/dictconfig.py
@@ -1,5 +1,5 @@
#
-# Copyright (C) 2009-2013 Vinay Sajip. See LICENSE.txt for details.
+# Copyright (C) 2009-2017 Vinay Sajip. See LICENSE.txt for details.
#
import logging.handlers
import re
diff --git a/logutils/http.py b/logutils/http.py
index 5d145c3..d1fe99d 100644
--- a/logutils/http.py
+++ b/logutils/http.py
@@ -1,5 +1,5 @@
#
-# Copyright (C) 2010-2013 Vinay Sajip. See LICENSE.txt for details.
+# Copyright (C) 2010-2017 Vinay Sajip. See LICENSE.txt for details.
#
import logging
@@ -37,7 +37,7 @@ class HTTPHandler(logging.Handler):
Default implementation of mapping the log record into a dict
that is sent as the CGI data. Overwrite in your class.
Contributed by Franz Glasner.
-
+
:param record: The record to be mapped.
"""
return record.__dict__
@@ -87,4 +87,3 @@ class HTTPHandler(logging.Handler):
raise
except:
self.handleError(record)
-
diff --git a/logutils/queue.py b/logutils/queue.py
index cced8c5..fea91d8 100644
--- a/logutils/queue.py
+++ b/logutils/queue.py
@@ -1,5 +1,5 @@
#
-# Copyright (C) 2010-2013 Vinay Sajip. See LICENSE.txt for details.
+# Copyright (C) 2010-2017 Vinay Sajip. See LICENSE.txt for details.
#
"""
This module contains classes which help you work with queues. A typical
@@ -32,7 +32,7 @@ class QueueHandler(logging.Handler):
with a multiprocessing Queue to centralise logging to file in one process
(in a multi-process application), so as to avoid file write contention
between processes.
-
+
:param queue: The queue to send `LogRecords` to.
"""
@@ -50,7 +50,7 @@ class QueueHandler(logging.Handler):
The base implementation uses :meth:`~queue.Queue.put_nowait`. You may
want to override this method if you want to use blocking, timeouts or
custom queue implementations.
-
+
:param record: The record to enqueue.
"""
self.queue.put_nowait(record)
@@ -67,7 +67,7 @@ class QueueHandler(logging.Handler):
You might want to override this method if you want to convert
the record to a dict or JSON string, or send a modified copy
of the record while leaving the original intact.
-
+
:param record: The record to prepare.
"""
# The format operation gets traceback text into record.exc_text
@@ -87,7 +87,7 @@ class QueueHandler(logging.Handler):
Emit a record.
Writes the LogRecord to the queue, preparing it for pickling first.
-
+
:param record: The record to emit.
"""
try:
@@ -102,7 +102,7 @@ class QueueListener(object):
This class implements an internal threaded listener which watches for
LogRecords being added to a queue, removes them and passes them to a
list of handlers for processing.
-
+
:param record: The queue to listen to.
:param handlers: The handlers to invoke on everything received from
the queue.
@@ -126,7 +126,7 @@ class QueueListener(object):
The base implementation uses :meth:`~queue.Queue.get`. You may want to
override this method if you want to use timeouts or work with custom
queue implementations.
-
+
:param block: Whether to block if the queue is empty. If `False` and
the queue is empty, an :class:`~queue.Empty` exception
will be thrown.
@@ -151,7 +151,7 @@ class QueueListener(object):
This method just returns the passed-in record. You may want to
override this method if you need to do any custom marshalling or
manipulation of the record before passing it to the handlers.
-
+
:param record: The record to prepare.
"""
return record
@@ -222,4 +222,3 @@ class QueueListener(object):
self.enqueue_sentinel()
self._thread.join()
self._thread = None
-
diff --git a/logutils/redis.py b/logutils/redis.py
index 0fea2d1..a8ead30 100644
--- a/logutils/redis.py
+++ b/logutils/redis.py
@@ -1,5 +1,5 @@
#
-# Copyright (C) 2011-2013 Vinay Sajip. See LICENSE.txt for details.
+# Copyright (C) 2011-2017 Vinay Sajip. See LICENSE.txt for details.
#
"""
This module contains classes which help you work with Redis queues.
@@ -15,7 +15,7 @@ class RedisQueueHandler(QueueHandler):
"""
A QueueHandler implementation which pushes pickled
records to a Redis queue using a specified key.
-
+
:param key: The key to use for the queue. Defaults to
"python.logging".
:param redis: If specified, this instance is used to
@@ -31,7 +31,7 @@ class RedisQueueHandler(QueueHandler):
assert limit >= 0
self.limit = limit
QueueHandler.__init__(self, redis)
-
+
def enqueue(self, record):
s = pickle.dumps(vars(record))
self.queue.rpush(self.key, s)
@@ -42,7 +42,7 @@ class RedisQueueListener(QueueListener):
"""
A QueueListener implementation which fetches pickled
records from a Redis queue using a specified key.
-
+
:param key: The key to use for the queue. Defaults to
"python.logging".
:param redis: If specified, this instance is used to
@@ -63,7 +63,7 @@ class RedisQueueListener(QueueListener):
if block:
s = self.queue.blpop(self.key)[1]
else:
- s = self.queue.lpop(self.key)
+ s = self.queue.lpop(self.key)
if not s:
record = None
else:
@@ -72,4 +72,3 @@ class RedisQueueListener(QueueListener):
def enqueue_sentinel(self):
self.queue.rpush(self.key, '')
-
diff --git a/logutils/testing.py b/logutils/testing.py
index dfc8d21..3c61217 100644
--- a/logutils/testing.py
+++ b/logutils/testing.py
@@ -1,5 +1,5 @@
#
-# Copyright (C) 2010-2013 Vinay Sajip. See LICENSE.txt for details.
+# Copyright (C) 2010-2017 Vinay Sajip. See LICENSE.txt for details.
#
import logging
from logging.handlers import BufferingHandler
@@ -8,7 +8,7 @@ class TestHandler(BufferingHandler):
"""
This handler collects records in a buffer for later inspection by
your unit test code.
-
+
:param matcher: The :class:`~logutils.testing.Matcher` instance to
use for matching.
"""
@@ -54,9 +54,9 @@ class TestHandler(BufferingHandler):
Look for a saved dict whose keys/values match the supplied arguments.
Return `True` if found, else `False`.
-
+
:param kwargs: A set of keyword arguments whose names are LogRecord
- attributes and whose values are what you want to
+ attributes and whose values are what you want to
match in a stored LogRecord.
"""
result = False
@@ -74,7 +74,7 @@ class TestHandler(BufferingHandler):
buffer of stored records matches the list one-for-one.
Return `True` if exactly matched, else `False`.
-
+
:param kwarglist: A list of keyword-argument dictionaries, each of
which will be passed to :meth:`matches` with the
corresponding record from the buffer.
@@ -102,14 +102,14 @@ class Matcher(object):
:class:`logging.LogRecord` attributes with keyword arguments
passed to its :meth:`~logutils.testing.Matcher.matches` method.
"""
-
+
_partial_matches = ('msg', 'message')
"""
A list of :class:`logging.LogRecord` attribute names which
will be checked for partial matches. If not in this list,
an exact match will be attempted.
"""
-
+
def matches(self, d, **kwargs):
"""
Try to match a single dict with the supplied arguments.
@@ -117,11 +117,11 @@ class Matcher(object):
Keys whose values are strings and which are in self._partial_matches
will be checked for partial (i.e. substring) matches. You can extend
this scheme to (for example) do regular expression matching, etc.
-
+
Return `True` if found, else `False`.
:param kwargs: A set of keyword arguments whose names are LogRecord
- attributes and whose values are what you want to
+ attributes and whose values are what you want to
match in a stored LogRecord.
"""
result = True
@@ -153,4 +153,3 @@ class Matcher(object):
#if not result:
# print('*** matcher failed on %s: %r vs. %r' % (k, dv, v))
return result
-
diff --git a/setup.py b/setup.py
index e2911e8..7ee0117 100644
--- a/setup.py
+++ b/setup.py
@@ -22,7 +22,7 @@ class TestCommand(distutils.core.Command):
def run(self):
import sys
import unittest
-
+
sys.path.append(join(dirname(__file__), 'tests'))
import logutil_tests
loader = unittest.TestLoader()
@@ -45,7 +45,7 @@ distutils.core.setup(
url='http://code.google.com/p/logutils/',
description='Logging utilities',
long_description = description(),
- license='Copyright (C) 2010-2013 by Vinay Sajip. All Rights Reserved. See LICENSE.txt for license.',
+ license='Copyright (C) 2010-2017 by Vinay Sajip. All Rights Reserved. See LICENSE.txt for license.',
classifiers=[
'Development Status :: 5 - Production/Stable',
'Environment :: Console',
@@ -61,5 +61,5 @@ distutils.core.setup(
cmdclass={
'test': TestCommand,
},
-
+
)
diff --git a/tests/logutil_tests.py b/tests/logutil_tests.py
index 5a9996d..e86d106 100644
--- a/tests/logutil_tests.py
+++ b/tests/logutil_tests.py
@@ -1,5 +1,5 @@
#
-# Copyright (C) 2008-2013 Vinay Sajip. See LICENSE.txt for details.
+# Copyright (C) 2008-2017 Vinay Sajip. See LICENSE.txt for details.
#
import sys
from test_testing import LoggingTest
diff --git a/tests/mytest.py b/tests/mytest.py
index 1c3fdd6..a5f40d3 100644
--- a/tests/mytest.py
+++ b/tests/mytest.py
@@ -5,5 +5,3 @@ from logutils.testing import TestHandler, Matcher
class MyTestHandler(TestHandler):
def __init__(self):
TestHandler.__init__(self, Matcher())
-
-
diff --git a/tests/test_adapter.py b/tests/test_adapter.py
index 0b7e1fa..d29bd10 100644
--- a/tests/test_adapter.py
+++ b/tests/test_adapter.py
@@ -1,5 +1,5 @@
#
-# Copyright (C) 2008-2013 Vinay Sajip. See LICENSE.txt for details.
+# Copyright (C) 2008-2017 Vinay Sajip. See LICENSE.txt for details.
#
import logging
from logutils.adapter import LoggerAdapter
@@ -67,4 +67,3 @@ class AdapterTest(unittest.TestCase):
if __name__ == '__main__':
unittest.main()
-
diff --git a/tests/test_colorize.py b/tests/test_colorize.py
index 5ec0bb4..022b631 100644
--- a/tests/test_colorize.py
+++ b/tests/test_colorize.py
@@ -1,5 +1,5 @@
#
-# Copyright (C) 2012-2013 Vinay Sajip. See LICENSE.txt for details.
+# Copyright (C) 2012-2017 Vinay Sajip. See LICENSE.txt for details.
#
import logging
import logutils.colorize
@@ -22,4 +22,3 @@ class ColorizeTest(unittest.TestCase):
logger.warning(u('Some unicode string with some \u015b\u0107\u017a\xf3\u0142 chars'))
finally:
logger.removeHandler(handler)
-
diff --git a/tests/test_dictconfig.py b/tests/test_dictconfig.py
index ff94a4d..3aee984 100644
--- a/tests/test_dictconfig.py
+++ b/tests/test_dictconfig.py
@@ -1,5 +1,5 @@
#
-# Copyright 2009-2013 by Vinay Sajip. See LICENSE.txt for details.
+# Copyright 2009-2017 by Vinay Sajip. See LICENSE.txt for details.
#
import logging
from logutils.adapter import LoggerAdapter
@@ -695,4 +695,3 @@ class ConfigDictTest(unittest.TestCase):
h = logging.getLogger().handlers[0]
self.assertEqual(h.__module__, 'mytest')
self.assertEqual(h.__class__.__name__, 'MyTestHandler')
-
diff --git a/tests/test_formatter.py b/tests/test_formatter.py
index 0e73ecf..0a069c7 100644
--- a/tests/test_formatter.py
+++ b/tests/test_formatter.py
@@ -1,5 +1,5 @@
#
-# Copyright (C) 2009-2013 Vinay Sajip. See LICENSE.txt for details.
+# Copyright (C) 2009-2017 Vinay Sajip. See LICENSE.txt for details.
#
import logging
import logutils
@@ -71,5 +71,3 @@ class FormatterTest(unittest.TestCase):
self.assertTrue(f.usesTime())
f = logutils.Formatter('asctime', style='$')
self.assertFalse(f.usesTime())
-
-
diff --git a/tests/test_messages.py b/tests/test_messages.py
index 6ceed42..17f80bb 100644
--- a/tests/test_messages.py
+++ b/tests/test_messages.py
@@ -13,7 +13,7 @@ class MessageTest(unittest.TestCase):
self.assertEqual(str(m), 'Message with 2 placeholders')
m = __('Message without {0:x} {1}', 16, 'placeholders')
self.assertEqual(str(m), 'Message without 10 placeholders')
-
+
class Dummy:
pass
@@ -31,5 +31,3 @@ class MessageTest(unittest.TestCase):
ignored = object()
self.assertRaises(TypeError, __, 'Message with $num ${what}',
ignored, num=2, what='placeholders')
-
-
diff --git a/tests/test_queue.py b/tests/test_queue.py
index 5969d0e..34152e3 100644
--- a/tests/test_queue.py
+++ b/tests/test_queue.py
@@ -1,5 +1,5 @@
#
-# Copyright (C) 2010-2013 Vinay Sajip. See LICENSE.txt for details.
+# Copyright (C) 2010-2017 Vinay Sajip. See LICENSE.txt for details.
#
import logging
from logutils.testing import TestHandler, Matcher
@@ -67,4 +67,3 @@ class QueueTest(unittest.TestCase):
if __name__ == '__main__':
unittest.main()
-
diff --git a/tests/test_redis.py b/tests/test_redis.py
index dfa7a8f..858192c 100644
--- a/tests/test_redis.py
+++ b/tests/test_redis.py
@@ -1,5 +1,5 @@
#
-# Copyright (C) 2011-2013 Vinay Sajip. See LICENSE.txt for details.
+# Copyright (C) 2011-2017 Vinay Sajip. See LICENSE.txt for details.
#
import logging
from logutils.testing import TestHandler, Matcher
@@ -49,7 +49,7 @@ class RedisQueueTest(unittest.TestCase):
if time.time() >= maxtime:
raise Exception('unable to connect to Redis server')
sock.close()
-
+
def test_simple(self):
"Simple test of queue handling and listening."
# Just as a demo, let's log some messages.
@@ -96,4 +96,3 @@ class RedisQueueTest(unittest.TestCase):
if __name__ == '__main__':
unittest.main()
-
diff --git a/tests/test_testing.py b/tests/test_testing.py
index f01fc09..c0b7409 100644
--- a/tests/test_testing.py
+++ b/tests/test_testing.py
@@ -1,5 +1,5 @@
#
-# Copyright (C) 2010-2013 Vinay Sajip. See LICENSE.txt for details.
+# Copyright (C) 2010-2017 Vinay Sajip. See LICENSE.txt for details.
#
import logging
from logutils.testing import TestHandler, Matcher
@@ -57,4 +57,3 @@ class LoggingTest(unittest.TestCase):
if __name__ == '__main__':
unittest.main()
-