summaryrefslogtreecommitdiffstats
path: root/Lib
diff options
context:
space:
mode:
authorVinay Sajip <vinay_sajip@yahoo.co.uk>2010-09-21 11:25:39 (GMT)
committerVinay Sajip <vinay_sajip@yahoo.co.uk>2010-09-21 11:25:39 (GMT)
commitc84f01698874902863396e82a248f5fd6ec59d0e (patch)
treeff6f8d60ab21f6aeb1d4ca5c35ba4555b5e697bf /Lib
parentceff5668864f319d05a781e8eef591b014ae2751 (diff)
downloadcpython-c84f01698874902863396e82a248f5fd6ec59d0e.zip
cpython-c84f01698874902863396e82a248f5fd6ec59d0e.tar.gz
cpython-c84f01698874902863396e82a248f5fd6ec59d0e.tar.bz2
Added some methods to LoggerAdapter, and updated documentation.
Diffstat (limited to 'Lib')
-rw-r--r--Lib/logging/__init__.py14
-rw-r--r--Lib/logging/handlers.py2
-rw-r--r--Lib/test/test_logging.py2
3 files changed, 17 insertions, 1 deletions
diff --git a/Lib/logging/__init__.py b/Lib/logging/__init__.py
index 42b957c..b7086d5 100644
--- a/Lib/logging/__init__.py
+++ b/Lib/logging/__init__.py
@@ -1400,6 +1400,8 @@ class LoggerAdapter(object):
msg, kwargs = self.process(msg, kwargs)
self.logger.warning(msg, *args, **kwargs)
+ warn = warning
+
def error(self, msg, *args, **kwargs):
"""
Delegate an error call to the underlying logger, after adding
@@ -1433,12 +1435,24 @@ class LoggerAdapter(object):
msg, kwargs = self.process(msg, kwargs)
self.logger.log(level, msg, *args, **kwargs)
+ def setLevel(self, level):
+ """
+ Set the specified level on the underlying logger.
+ """
+ self.logger.setLevel(level)
+
def isEnabledFor(self, level):
"""
See if the underlying logger is enabled for the specified level.
"""
return self.logger.isEnabledFor(level)
+ def getEffectiveLevel(self):
+ """
+ Get the effective level for the underlying logger.
+ """
+ return self.logger.getEffectiveLevel()
+
def hasHandlers(self):
"""
See if the underlying logger has any handlers.
diff --git a/Lib/logging/handlers.py b/Lib/logging/handlers.py
index 744f59b..ce0673d 100644
--- a/Lib/logging/handlers.py
+++ b/Lib/logging/handlers.py
@@ -1131,6 +1131,8 @@ class MemoryHandler(BufferingHandler):
For a MemoryHandler, flushing means just sending the buffered
records to the target, if there is one. Override if you want
different behaviour.
+
+ The record buffer is also cleared by this operation.
"""
if self.target:
for record in self.buffer:
diff --git a/Lib/test/test_logging.py b/Lib/test/test_logging.py
index 7506dba..c5d8bac 100644
--- a/Lib/test/test_logging.py
+++ b/Lib/test/test_logging.py
@@ -154,7 +154,7 @@ class BuiltinLevelsTest(BaseTest):
ERR = logging.getLogger("ERR")
ERR.setLevel(logging.ERROR)
- INF = logging.getLogger("INF")
+ INF = logging.LoggerAdapter(logging.getLogger("INF"), {})
INF.setLevel(logging.INFO)
DEB = logging.getLogger("DEB")
DEB.setLevel(logging.DEBUG)