summaryrefslogtreecommitdiff
path: root/repoze/bfg/log.py
diff options
context:
space:
mode:
authorChris McDonough <chrism@agendaless.com>2008-10-03 20:11:06 +0000
committerChris McDonough <chrism@agendaless.com>2008-10-03 20:11:06 +0000
commit47b4d3ee62dfdb830a83192907b0602218f9ab5e (patch)
tree6fe0cce905bcc39f1ab431101fe419f4197305f9 /repoze/bfg/log.py
parent68fe4a3a211176a282212a441d04ab53227f6bd2 (diff)
downloadpyramid-47b4d3ee62dfdb830a83192907b0602218f9ab5e.tar.gz
pyramid-47b4d3ee62dfdb830a83192907b0602218f9ab5e.tar.bz2
pyramid-47b4d3ee62dfdb830a83192907b0602218f9ab5e.zip
Docs
- An "Environment and Configuration" chapter was added to the narrative portion of the documentation. Features - Ensure bfg doesn't generate warnings when running under Python 2.6. - The environment variable ``BFG_RELOAD_TEMPLATES`` is now available (serves the same purpose as ``reload_templates`` in the config file). - A new configuration file option ``debug_authorization`` was added. This turns on printing of security authorization debug statements to ``sys.stderr``. The ``BFG_DEBUG_AUTHORIZATION`` environment variable was also added; this performs the same duty. Bug Fixes - The environment variable ``BFG_SECURITY_DEBUG`` did not always work. It has been renamed to ``BFG_DEBUG_AUTHORIZATION`` and fixed. Deprecations - A deprecation warning is now issued when old API names from the ``repoze.bfg.templates`` module are imported. Backwards incompatibilities - The ``BFG_SECURITY_DEBUG`` environment variable was renamed to ``BFG_DEBUG_AUTHORIZATION``.
Diffstat (limited to 'repoze/bfg/log.py')
-rw-r--r--repoze/bfg/log.py16
1 files changed, 16 insertions, 0 deletions
diff --git a/repoze/bfg/log.py b/repoze/bfg/log.py
new file mode 100644
index 000000000..ac2145a47
--- /dev/null
+++ b/repoze/bfg/log.py
@@ -0,0 +1,16 @@
+import logging
+
+def make_stream_logger(name, stream, levelname='DEBUG',
+ fmt='%(asctime)s %(message)s'):
+ """ Return an object which implements
+ ``repoze.bfg.interfaces.ILogger`` (ie. a Python PEP 282 logger
+ instance) with the name ``name`` using the stream (or open
+ filehandle) ``stream``, logging at ``levelname`` log level or
+ above with format ``fmt``. """
+ handler = logging.StreamHandler(stream)
+ formatter = logging.Formatter(fmt)
+ handler.setFormatter(formatter)
+ logger = logging.Logger(name)
+ logger.addHandler(handler)
+ logger.setLevel(getattr(logging, levelname))
+ return logger