summaryrefslogtreecommitdiff
path: root/Lib/test/test_logging.py
diff options
context:
space:
mode:
authorVinay Sajip <vinay_sajip@yahoo.co.uk>2010-03-22 15:29:01 +0000
committerVinay Sajip <vinay_sajip@yahoo.co.uk>2010-03-22 15:29:01 +0000
commit804899b4ab873144ffc12c145fc4266489454c21 (patch)
treec89bb1594b095118133cce17144ce430f8c1c3e2 /Lib/test/test_logging.py
parent73c22e9df2ec56ae5ff756d4af39d819a43af178 (diff)
downloadcpython-git-804899b4ab873144ffc12c145fc4266489454c21.tar.gz
logging: Added getChild utility method to Logger and added isEnabledFor method to LoggerAdapter.
Diffstat (limited to 'Lib/test/test_logging.py')
-rw-r--r--Lib/test/test_logging.py20
1 files changed, 19 insertions, 1 deletions
diff --git a/Lib/test/test_logging.py b/Lib/test/test_logging.py
index a918d6eca7..432493b8e5 100644
--- a/Lib/test/test_logging.py
+++ b/Lib/test/test_logging.py
@@ -1736,6 +1736,23 @@ class ManagerTest(BaseTest):
self.assertEqual(logged, ['should appear in logged'])
+class ChildLoggerTest(BaseTest):
+ def test_child_loggers(self):
+ r = logging.getLogger()
+ l1 = logging.getLogger('abc')
+ l2 = logging.getLogger('def.ghi')
+ c1 = r.getChild('xyz')
+ c2 = r.getChild('uvw.xyz')
+ self.assertTrue(c1 is logging.getLogger('xyz'))
+ self.assertTrue(c2 is logging.getLogger('uvw.xyz'))
+ c1 = l1.getChild('def')
+ c2 = c1.getChild('ghi')
+ c3 = l1.getChild('def.ghi')
+ self.assertTrue(c1 is logging.getLogger('abc.def'))
+ self.assertTrue(c2 is logging.getLogger('abc.def.ghi'))
+ self.assertTrue(c2 is c3)
+
+
# Set the locale to the platform-dependent default. I have no idea
# why the test does this, but in any case we save the current locale
# first and restore it at the end.
@@ -1744,7 +1761,8 @@ def test_main():
run_unittest(BuiltinLevelsTest, BasicFilterTest,
CustomLevelsAndFiltersTest, MemoryHandlerTest,
ConfigFileTest, SocketHandlerTest, MemoryTest,
- EncodingTest, WarningsTest, ConfigDictTest, ManagerTest)
+ EncodingTest, WarningsTest, ConfigDictTest, ManagerTest,
+ ChildLoggerTest)
if __name__ == "__main__":
test_main()