summaryrefslogtreecommitdiff
path: root/doc
diff options
context:
space:
mode:
authorVinay Sajip <vinay_sajip@yahoo.co.uk>2011-01-24 10:59:31 +0000
committerVinay Sajip <vinay_sajip@yahoo.co.uk>2011-01-24 10:59:31 +0000
commit644cbf93f0e4e73c076d26d7b4bce74744bf87d0 (patch)
tree9809a50297b764c18f2016c74b806be1ca447bae /doc
parent25f7fa03a204cce1e3f982ae2833af0d5af215ab (diff)
downloadlogutils-git-644cbf93f0e4e73c076d26d7b4bce74744bf87d0.tar.gz
More changes for 0.3.
Diffstat (limited to 'doc')
-rw-r--r--doc/adapter.rst16
-rw-r--r--doc/colorize.rst11
-rw-r--r--doc/dictconfig.rst15
-rw-r--r--doc/http.rst11
-rw-r--r--doc/libraries.rst25
-rw-r--r--doc/queue.rst6
-rw-r--r--doc/testing.rst65
7 files changed, 149 insertions, 0 deletions
diff --git a/doc/adapter.rst b/doc/adapter.rst
new file mode 100644
index 0000000..a277de4
--- /dev/null
+++ b/doc/adapter.rst
@@ -0,0 +1,16 @@
+Working with Logger adapters
+============================
+
+**N.B.** This is part of the standard library since Python 2.6 / 3.1, so the
+version here is for use with earlier Python versions.
+
+The class was enhanced for Python 3.2, so you may wish to use this version
+with earlier Python versions.
+
+However, note that the :class:`~logutils.adapter.LoggerAdapter` class will **not**
+work with Python 2.4 or earlier, as it uses the `extra` keyword argument which
+was added in later Python versions.
+
+.. automodule:: logutils.adapter
+ :members:
+
diff --git a/doc/colorize.rst b/doc/colorize.rst
new file mode 100644
index 0000000..f18a656
--- /dev/null
+++ b/doc/colorize.rst
@@ -0,0 +1,11 @@
+Colorizing Console Streams
+==========================
+
+``ColorizingStreamHandler`` is a handler which allows colorizing of console
+streams, described here_ in more detail.
+
+.. _here: http://plumberjack.blogspot.com/2010/12/colorizing-logging-output-in-terminals.html
+
+.. automodule:: logutils.colorize
+ :members:
+
diff --git a/doc/dictconfig.rst b/doc/dictconfig.rst
new file mode 100644
index 0000000..575e370
--- /dev/null
+++ b/doc/dictconfig.rst
@@ -0,0 +1,15 @@
+Dictionary-based Configuration
+==============================
+
+This module implements dictionary-based configuration according to PEP 391.
+
+**N.B.** This is part of the standard library since Python 2.7 / 3.2, so the
+version here is for use with earlier Python versions.
+
+.. automodule:: logutils.dictconfig
+
+.. autoclass:: logutils.dictconfig.DictConfigurator
+ :members: configure
+
+.. autofunction:: dictConfig
+
diff --git a/doc/http.rst b/doc/http.rst
new file mode 100644
index 0000000..621292d
--- /dev/null
+++ b/doc/http.rst
@@ -0,0 +1,11 @@
+Working with web sites
+======================
+
+**N.B.** The :class:`~logutils.http.HTTPHandler` class has been present in the
+:mod:`logging` package since the first release, but was enhanced for Python
+3.2 to add options for secure connections and user credentials. You may wish
+to use this version with earlier Python releases.
+
+.. automodule:: logutils.http
+ :members:
+
diff --git a/doc/libraries.rst b/doc/libraries.rst
new file mode 100644
index 0000000..611a466
--- /dev/null
+++ b/doc/libraries.rst
@@ -0,0 +1,25 @@
+Configuring Libraries
+=====================
+
+When developing libraries, you'll probably need to use the
+:class:`~logutils.NullHandler` class.
+
+**N.B.** This is part of the standard library since Python 2.7 / 3.1, so the
+version here is for use with earlier Python versions.
+
+Typical usage::
+
+ import logging
+ try:
+ from logging import NullHandler
+ except ImportError:
+ from logutils import NullHandler
+
+ # use this in all your library's subpackages/submodules
+ logger = logging.getLogger(__name__)
+
+ # use this just in your library's top-level package
+ logger.addHandler(NullHandler())
+
+.. autoclass:: logutils.NullHandler
+ :members:
diff --git a/doc/queue.rst b/doc/queue.rst
new file mode 100644
index 0000000..984631f
--- /dev/null
+++ b/doc/queue.rst
@@ -0,0 +1,6 @@
+Working with queues
+===================
+
+.. automodule:: logutils.queue
+ :members:
+
diff --git a/doc/testing.rst b/doc/testing.rst
new file mode 100644
index 0000000..1f959ca
--- /dev/null
+++ b/doc/testing.rst
@@ -0,0 +1,65 @@
+Unit testing
+============
+
+When developing unit tests, you may find the
+:class:`~logutils.testing.TestHandler` and :class:`~logutils.testing.Matcher`
+classes useful.
+
+Typical usage::
+
+ import logging
+ from logutils.testing import TestHandler, Matcher
+ import unittest
+
+ class LoggingTest(unittest.TestCase):
+ def setUp(self):
+ self.handler = h = TestHandler(Matcher())
+ self.logger = l = logging.getLogger()
+ l.addHandler(h)
+
+ def tearDown(self):
+ self.logger.removeHandler(self.handler)
+ self.handler.close()
+
+ def test_simple(self):
+ "Simple test of logging test harness."
+ # Just as a demo, let's log some messages.
+ # Only one should show up in the log.
+ self.logger.debug("This won't show up.")
+ self.logger.info("Neither will this.")
+ self.logger.warning("But this will.")
+ h = self.handler
+ self.assertTrue(h.matches(levelno=logging.WARNING))
+ self.assertFalse(h.matches(levelno=logging.DEBUG))
+ self.assertFalse(h.matches(levelno=logging.INFO))
+
+ def test_partial(self):
+ "Test of partial matching in logging test harness."
+ # Just as a demo, let's log some messages.
+ # Only one should show up in the log.
+ self.logger.debug("This won't show up.")
+ self.logger.info("Neither will this.")
+ self.logger.warning("But this will.")
+ h = self.handler
+ self.assertTrue(h.matches(msg="ut th")) # from "But this will"
+ self.assertTrue(h.matches(message="ut th")) # from "But this will"
+ self.assertFalse(h.matches(message="either"))
+ self.assertFalse(h.matches(message="won't"))
+
+ def test_multiple(self):
+ "Test of matching multiple values in logging test harness."
+ # Just as a demo, let's log some messages.
+ # Only one should show up in the log.
+ self.logger.debug("This won't show up.")
+ self.logger.info("Neither will this.")
+ self.logger.warning("But this will.")
+ self.logger.error("And so will this.")
+ h = self.handler
+ self.assertTrue(h.matches(levelno=logging.WARNING,
+ message='ut thi'))
+ self.assertTrue(h.matches(levelno=logging.ERROR,
+ message='nd so wi'))
+ self.assertFalse(h.matches(levelno=logging.INFO))
+
+.. automodule:: logutils.testing
+ :members: