summaryrefslogtreecommitdiffstats
path: root/Lib/logging
diff options
context:
space:
mode:
Diffstat (limited to 'Lib/logging')
-rw-r--r--Lib/logging/__init__.py27
1 files changed, 27 insertions, 0 deletions
diff --git a/Lib/logging/__init__.py b/Lib/logging/__init__.py
index fd422ea..4d872bd 100644
--- a/Lib/logging/__init__.py
+++ b/Lib/logging/__init__.py
@@ -935,6 +935,10 @@ class Handler(Filterer):
finally:
del t, v, tb
+ def __repr__(self):
+ level = getLevelName(self.level)
+ return '<%s (%s)>' % (self.__class__.__name__, level)
+
class StreamHandler(Handler):
"""
A handler class which writes logging records, appropriately formatted,
@@ -986,6 +990,14 @@ class StreamHandler(Handler):
except Exception:
self.handleError(record)
+ def __repr__(self):
+ level = getLevelName(self.level)
+ name = getattr(self.stream, 'name', '')
+ if name:
+ name += ' '
+ return '<%s %s(%s)>' % (self.__class__.__name__, name, level)
+
+
class FileHandler(StreamHandler):
"""
A handler class which writes formatted logging records to disk files.
@@ -1050,6 +1062,11 @@ class FileHandler(StreamHandler):
self.stream = self._open()
StreamHandler.emit(self, record)
+ def __repr__(self):
+ level = getLevelName(self.level)
+ return '<%s %s (%s)>' % (self.__class__.__name__, self.baseFilename, level)
+
+
class _StderrHandler(StreamHandler):
"""
This class is like a StreamHandler using sys.stderr, but always uses
@@ -1542,6 +1559,11 @@ class Logger(Filterer):
suffix = '.'.join((self.name, suffix))
return self.manager.getLogger(suffix)
+ def __repr__(self):
+ level = getLevelName(self.getEffectiveLevel())
+ return '<%s %s (%s)>' % (self.__class__.__name__, self.name, level)
+
+
class RootLogger(Logger):
"""
A root logger is not that different to any other logger, except that
@@ -1668,6 +1690,11 @@ class LoggerAdapter(object):
"""
return self.logger.hasHandlers()
+ def __repr__(self):
+ logger = self.logger
+ level = getLevelName(logger.getEffectiveLevel())
+ return '<%s %s (%s)>' % (self.__class__.__name__, logger.name, level)
+
root = RootLogger(WARNING)
Logger.root = root
Logger.manager = Manager(Logger.root)