summaryrefslogtreecommitdiff
path: root/logutils
diff options
context:
space:
mode:
Diffstat (limited to 'logutils')
-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
8 files changed, 33 insertions, 40 deletions
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
-