summaryrefslogtreecommitdiffstats
path: root/Lib/test
diff options
context:
space:
mode:
authorNeal Norwitz <nnorwitz@gmail.com>2003-01-02 14:56:39 (GMT)
committerNeal Norwitz <nnorwitz@gmail.com>2003-01-02 14:56:39 (GMT)
commitb4a2df0c8dce4e354e72ad2ad37c98adb1c9fc85 (patch)
tree87609c337cb1c7b3eb45100cd7a7204a29433148 /Lib/test
parent9e86ad70722d5e825d1db309e18864e5aa47dbf1 (diff)
downloadcpython-b4a2df0c8dce4e354e72ad2ad37c98adb1c9fc85.zip
cpython-b4a2df0c8dce4e354e72ad2ad37c98adb1c9fc85.tar.gz
cpython-b4a2df0c8dce4e354e72ad2ad37c98adb1c9fc85.tar.bz2
SF #660795
Add a test for logging from Vinay Sajip (module author)
Diffstat (limited to 'Lib/test')
-rw-r--r--Lib/test/output/test_logging516
-rw-r--r--Lib/test/test_logging.py459
2 files changed, 975 insertions, 0 deletions
diff --git a/Lib/test/output/test_logging b/Lib/test/output/test_logging
new file mode 100644
index 0000000..9e52c03
--- /dev/null
+++ b/Lib/test/output/test_logging
@@ -0,0 +1,516 @@
+test_logging
+About to start TCP server...
+-- log_test0 begin ---------------------------------------------------
+CRITICAL:ERR:Message 0
+ERROR:ERR:Message 1
+CRITICAL:INF:Message 2
+ERROR:INF:Message 3
+WARN:INF:Message 4
+INFO:INF:Message 5
+CRITICAL:INF.UNDEF:Message 6
+ERROR:INF.UNDEF:Message 7
+WARN:INF.UNDEF:Message 8
+INFO:INF.UNDEF:Message 9
+CRITICAL:INF.ERR:Message 10
+ERROR:INF.ERR:Message 11
+CRITICAL:INF.ERR.UNDEF:Message 12
+ERROR:INF.ERR.UNDEF:Message 13
+CRITICAL:DEB:Message 14
+ERROR:DEB:Message 15
+WARN:DEB:Message 16
+INFO:DEB:Message 17
+DEBUG:DEB:Message 18
+CRITICAL:UNDEF:Message 19
+ERROR:UNDEF:Message 20
+WARN:UNDEF:Message 21
+INFO:UNDEF:Message 22
+CRITICAL:INF.BADPARENT.UNDEF:Message 23
+CRITICAL:INF.BADPARENT:Message 24
+INFO:INF:Messages should bear numbers 0 through 24.
+-- log_test0 end ---------------------------------------------------
+-- log_test1 begin ---------------------------------------------------
+-- setting logging level to 'Boring' -----
+Boring:root:This should only be seen at the 'Boring' logging level (or lower)
+Chatterbox:root:This should only be seen at the 'Chatterbox' logging level (or lower)
+Garrulous:root:This should only be seen at the 'Garrulous' logging level (or lower)
+Talkative:root:This should only be seen at the 'Talkative' logging level (or lower)
+Verbose:root:This should only be seen at the 'Verbose' logging level (or lower)
+Sociable:root:This should only be seen at the 'Sociable' logging level (or lower)
+Effusive:root:This should only be seen at the 'Effusive' logging level (or lower)
+Terse:root:This should only be seen at the 'Terse' logging level (or lower)
+Taciturn:root:This should only be seen at the 'Taciturn' logging level (or lower)
+Silent:root:This should only be seen at the 'Silent' logging level (or lower)
+-- setting logging level to 'Chatterbox' -----
+Chatterbox:root:This should only be seen at the 'Chatterbox' logging level (or lower)
+Garrulous:root:This should only be seen at the 'Garrulous' logging level (or lower)
+Talkative:root:This should only be seen at the 'Talkative' logging level (or lower)
+Verbose:root:This should only be seen at the 'Verbose' logging level (or lower)
+Sociable:root:This should only be seen at the 'Sociable' logging level (or lower)
+Effusive:root:This should only be seen at the 'Effusive' logging level (or lower)
+Terse:root:This should only be seen at the 'Terse' logging level (or lower)
+Taciturn:root:This should only be seen at the 'Taciturn' logging level (or lower)
+Silent:root:This should only be seen at the 'Silent' logging level (or lower)
+-- setting logging level to 'Garrulous' -----
+Garrulous:root:This should only be seen at the 'Garrulous' logging level (or lower)
+Talkative:root:This should only be seen at the 'Talkative' logging level (or lower)
+Verbose:root:This should only be seen at the 'Verbose' logging level (or lower)
+Sociable:root:This should only be seen at the 'Sociable' logging level (or lower)
+Effusive:root:This should only be seen at the 'Effusive' logging level (or lower)
+Terse:root:This should only be seen at the 'Terse' logging level (or lower)
+Taciturn:root:This should only be seen at the 'Taciturn' logging level (or lower)
+Silent:root:This should only be seen at the 'Silent' logging level (or lower)
+-- setting logging level to 'Talkative' -----
+Talkative:root:This should only be seen at the 'Talkative' logging level (or lower)
+Verbose:root:This should only be seen at the 'Verbose' logging level (or lower)
+Sociable:root:This should only be seen at the 'Sociable' logging level (or lower)
+Effusive:root:This should only be seen at the 'Effusive' logging level (or lower)
+Terse:root:This should only be seen at the 'Terse' logging level (or lower)
+Taciturn:root:This should only be seen at the 'Taciturn' logging level (or lower)
+Silent:root:This should only be seen at the 'Silent' logging level (or lower)
+-- setting logging level to 'Verbose' -----
+Verbose:root:This should only be seen at the 'Verbose' logging level (or lower)
+Sociable:root:This should only be seen at the 'Sociable' logging level (or lower)
+Effusive:root:This should only be seen at the 'Effusive' logging level (or lower)
+Terse:root:This should only be seen at the 'Terse' logging level (or lower)
+Taciturn:root:This should only be seen at the 'Taciturn' logging level (or lower)
+Silent:root:This should only be seen at the 'Silent' logging level (or lower)
+-- setting logging level to 'Sociable' -----
+Sociable:root:This should only be seen at the 'Sociable' logging level (or lower)
+Effusive:root:This should only be seen at the 'Effusive' logging level (or lower)
+Terse:root:This should only be seen at the 'Terse' logging level (or lower)
+Taciturn:root:This should only be seen at the 'Taciturn' logging level (or lower)
+Silent:root:This should only be seen at the 'Silent' logging level (or lower)
+-- setting logging level to 'Effusive' -----
+Effusive:root:This should only be seen at the 'Effusive' logging level (or lower)
+Terse:root:This should only be seen at the 'Terse' logging level (or lower)
+Taciturn:root:This should only be seen at the 'Taciturn' logging level (or lower)
+Silent:root:This should only be seen at the 'Silent' logging level (or lower)
+-- setting logging level to 'Terse' -----
+Terse:root:This should only be seen at the 'Terse' logging level (or lower)
+Taciturn:root:This should only be seen at the 'Taciturn' logging level (or lower)
+Silent:root:This should only be seen at the 'Silent' logging level (or lower)
+-- setting logging level to 'Taciturn' -----
+Taciturn:root:This should only be seen at the 'Taciturn' logging level (or lower)
+Silent:root:This should only be seen at the 'Silent' logging level (or lower)
+-- setting logging level to 'Silent' -----
+Silent:root:This should only be seen at the 'Silent' logging level (or lower)
+-- Filtering at handler level to SOCIABLE --
+-- setting logging level to 'Boring' -----
+Sociable:root:This should only be seen at the 'Sociable' logging level (or lower)
+Effusive:root:This should only be seen at the 'Effusive' logging level (or lower)
+Terse:root:This should only be seen at the 'Terse' logging level (or lower)
+Taciturn:root:This should only be seen at the 'Taciturn' logging level (or lower)
+Silent:root:This should only be seen at the 'Silent' logging level (or lower)
+-- setting logging level to 'Chatterbox' -----
+Sociable:root:This should only be seen at the 'Sociable' logging level (or lower)
+Effusive:root:This should only be seen at the 'Effusive' logging level (or lower)
+Terse:root:This should only be seen at the 'Terse' logging level (or lower)
+Taciturn:root:This should only be seen at the 'Taciturn' logging level (or lower)
+Silent:root:This should only be seen at the 'Silent' logging level (or lower)
+-- setting logging level to 'Garrulous' -----
+Sociable:root:This should only be seen at the 'Sociable' logging level (or lower)
+Effusive:root:This should only be seen at the 'Effusive' logging level (or lower)
+Terse:root:This should only be seen at the 'Terse' logging level (or lower)
+Taciturn:root:This should only be seen at the 'Taciturn' logging level (or lower)
+Silent:root:This should only be seen at the 'Silent' logging level (or lower)
+-- setting logging level to 'Talkative' -----
+Sociable:root:This should only be seen at the 'Sociable' logging level (or lower)
+Effusive:root:This should only be seen at the 'Effusive' logging level (or lower)
+Terse:root:This should only be seen at the 'Terse' logging level (or lower)
+Taciturn:root:This should only be seen at the 'Taciturn' logging level (or lower)
+Silent:root:This should only be seen at the 'Silent' logging level (or lower)
+-- setting logging level to 'Verbose' -----
+Sociable:root:This should only be seen at the 'Sociable' logging level (or lower)
+Effusive:root:This should only be seen at the 'Effusive' logging level (or lower)
+Terse:root:This should only be seen at the 'Terse' logging level (or lower)
+Taciturn:root:This should only be seen at the 'Taciturn' logging level (or lower)
+Silent:root:This should only be seen at the 'Silent' logging level (or lower)
+-- setting logging level to 'Sociable' -----
+Sociable:root:This should only be seen at the 'Sociable' logging level (or lower)
+Effusive:root:This should only be seen at the 'Effusive' logging level (or lower)
+Terse:root:This should only be seen at the 'Terse' logging level (or lower)
+Taciturn:root:This should only be seen at the 'Taciturn' logging level (or lower)
+Silent:root:This should only be seen at the 'Silent' logging level (or lower)
+-- setting logging level to 'Effusive' -----
+Effusive:root:This should only be seen at the 'Effusive' logging level (or lower)
+Terse:root:This should only be seen at the 'Terse' logging level (or lower)
+Taciturn:root:This should only be seen at the 'Taciturn' logging level (or lower)
+Silent:root:This should only be seen at the 'Silent' logging level (or lower)
+-- setting logging level to 'Terse' -----
+Terse:root:This should only be seen at the 'Terse' logging level (or lower)
+Taciturn:root:This should only be seen at the 'Taciturn' logging level (or lower)
+Silent:root:This should only be seen at the 'Silent' logging level (or lower)
+-- setting logging level to 'Taciturn' -----
+Taciturn:root:This should only be seen at the 'Taciturn' logging level (or lower)
+Silent:root:This should only be seen at the 'Silent' logging level (or lower)
+-- setting logging level to 'Silent' -----
+Silent:root:This should only be seen at the 'Silent' logging level (or lower)
+-- Filtering using GARRULOUS filter --
+-- setting logging level to 'Boring' -----
+Boring:root:This should only be seen at the 'Boring' logging level (or lower)
+Chatterbox:root:This should only be seen at the 'Chatterbox' logging level (or lower)
+Talkative:root:This should only be seen at the 'Talkative' logging level (or lower)
+Verbose:root:This should only be seen at the 'Verbose' logging level (or lower)
+Sociable:root:This should only be seen at the 'Sociable' logging level (or lower)
+Effusive:root:This should only be seen at the 'Effusive' logging level (or lower)
+Terse:root:This should only be seen at the 'Terse' logging level (or lower)
+Taciturn:root:This should only be seen at the 'Taciturn' logging level (or lower)
+Silent:root:This should only be seen at the 'Silent' logging level (or lower)
+-- setting logging level to 'Chatterbox' -----
+Chatterbox:root:This should only be seen at the 'Chatterbox' logging level (or lower)
+Talkative:root:This should only be seen at the 'Talkative' logging level (or lower)
+Verbose:root:This should only be seen at the 'Verbose' logging level (or lower)
+Sociable:root:This should only be seen at the 'Sociable' logging level (or lower)
+Effusive:root:This should only be seen at the 'Effusive' logging level (or lower)
+Terse:root:This should only be seen at the 'Terse' logging level (or lower)
+Taciturn:root:This should only be seen at the 'Taciturn' logging level (or lower)
+Silent:root:This should only be seen at the 'Silent' logging level (or lower)
+-- setting logging level to 'Garrulous' -----
+Talkative:root:This should only be seen at the 'Talkative' logging level (or lower)
+Verbose:root:This should only be seen at the 'Verbose' logging level (or lower)
+Sociable:root:This should only be seen at the 'Sociable' logging level (or lower)
+Effusive:root:This should only be seen at the 'Effusive' logging level (or lower)
+Terse:root:This should only be seen at the 'Terse' logging level (or lower)
+Taciturn:root:This should only be seen at the 'Taciturn' logging level (or lower)
+Silent:root:This should only be seen at the 'Silent' logging level (or lower)
+-- setting logging level to 'Talkative' -----
+Talkative:root:This should only be seen at the 'Talkative' logging level (or lower)
+Verbose:root:This should only be seen at the 'Verbose' logging level (or lower)
+Sociable:root:This should only be seen at the 'Sociable' logging level (or lower)
+Effusive:root:This should only be seen at the 'Effusive' logging level (or lower)
+Terse:root:This should only be seen at the 'Terse' logging level (or lower)
+Taciturn:root:This should only be seen at the 'Taciturn' logging level (or lower)
+Silent:root:This should only be seen at the 'Silent' logging level (or lower)
+-- setting logging level to 'Verbose' -----
+Verbose:root:This should only be seen at the 'Verbose' logging level (or lower)
+Sociable:root:This should only be seen at the 'Sociable' logging level (or lower)
+Effusive:root:This should only be seen at the 'Effusive' logging level (or lower)
+Terse:root:This should only be seen at the 'Terse' logging level (or lower)
+Taciturn:root:This should only be seen at the 'Taciturn' logging level (or lower)
+Silent:root:This should only be seen at the 'Silent' logging level (or lower)
+-- setting logging level to 'Sociable' -----
+Sociable:root:This should only be seen at the 'Sociable' logging level (or lower)
+Effusive:root:This should only be seen at the 'Effusive' logging level (or lower)
+Terse:root:This should only be seen at the 'Terse' logging level (or lower)
+Taciturn:root:This should only be seen at the 'Taciturn' logging level (or lower)
+Silent:root:This should only be seen at the 'Silent' logging level (or lower)
+-- setting logging level to 'Effusive' -----
+Effusive:root:This should only be seen at the 'Effusive' logging level (or lower)
+Terse:root:This should only be seen at the 'Terse' logging level (or lower)
+Taciturn:root:This should only be seen at the 'Taciturn' logging level (or lower)
+Silent:root:This should only be seen at the 'Silent' logging level (or lower)
+-- setting logging level to 'Terse' -----
+Terse:root:This should only be seen at the 'Terse' logging level (or lower)
+Taciturn:root:This should only be seen at the 'Taciturn' logging level (or lower)
+Silent:root:This should only be seen at the 'Silent' logging level (or lower)
+-- setting logging level to 'Taciturn' -----
+Taciturn:root:This should only be seen at the 'Taciturn' logging level (or lower)
+Silent:root:This should only be seen at the 'Silent' logging level (or lower)
+-- setting logging level to 'Silent' -----
+Silent:root:This should only be seen at the 'Silent' logging level (or lower)
+-- Filtering using specific filter for SOCIABLE, TACITURN --
+-- setting logging level to 'Boring' -----
+Boring:root:This should only be seen at the 'Boring' logging level (or lower)
+Chatterbox:root:This should only be seen at the 'Chatterbox' logging level (or lower)
+Talkative:root:This should only be seen at the 'Talkative' logging level (or lower)
+Verbose:root:This should only be seen at the 'Verbose' logging level (or lower)
+Effusive:root:This should only be seen at the 'Effusive' logging level (or lower)
+Terse:root:This should only be seen at the 'Terse' logging level (or lower)
+Silent:root:This should only be seen at the 'Silent' logging level (or lower)
+-- setting logging level to 'Chatterbox' -----
+Chatterbox:root:This should only be seen at the 'Chatterbox' logging level (or lower)
+Talkative:root:This should only be seen at the 'Talkative' logging level (or lower)
+Verbose:root:This should only be seen at the 'Verbose' logging level (or lower)
+Effusive:root:This should only be seen at the 'Effusive' logging level (or lower)
+Terse:root:This should only be seen at the 'Terse' logging level (or lower)
+Silent:root:This should only be seen at the 'Silent' logging level (or lower)
+-- setting logging level to 'Garrulous' -----
+Talkative:root:This should only be seen at the 'Talkative' logging level (or lower)
+Verbose:root:This should only be seen at the 'Verbose' logging level (or lower)
+Effusive:root:This should only be seen at the 'Effusive' logging level (or lower)
+Terse:root:This should only be seen at the 'Terse' logging level (or lower)
+Silent:root:This should only be seen at the 'Silent' logging level (or lower)
+-- setting logging level to 'Talkative' -----
+Talkative:root:This should only be seen at the 'Talkative' logging level (or lower)
+Verbose:root:This should only be seen at the 'Verbose' logging level (or lower)
+Effusive:root:This should only be seen at the 'Effusive' logging level (or lower)
+Terse:root:This should only be seen at the 'Terse' logging level (or lower)
+Silent:root:This should only be seen at the 'Silent' logging level (or lower)
+-- setting logging level to 'Verbose' -----
+Verbose:root:This should only be seen at the 'Verbose' logging level (or lower)
+Effusive:root:This should only be seen at the 'Effusive' logging level (or lower)
+Terse:root:This should only be seen at the 'Terse' logging level (or lower)
+Silent:root:This should only be seen at the 'Silent' logging level (or lower)
+-- setting logging level to 'Sociable' -----
+Effusive:root:This should only be seen at the 'Effusive' logging level (or lower)
+Terse:root:This should only be seen at the 'Terse' logging level (or lower)
+Silent:root:This should only be seen at the 'Silent' logging level (or lower)
+-- setting logging level to 'Effusive' -----
+Effusive:root:This should only be seen at the 'Effusive' logging level (or lower)
+Terse:root:This should only be seen at the 'Terse' logging level (or lower)
+Silent:root:This should only be seen at the 'Silent' logging level (or lower)
+-- setting logging level to 'Terse' -----
+Terse:root:This should only be seen at the 'Terse' logging level (or lower)
+Silent:root:This should only be seen at the 'Silent' logging level (or lower)
+-- setting logging level to 'Taciturn' -----
+Silent:root:This should only be seen at the 'Silent' logging level (or lower)
+-- setting logging level to 'Silent' -----
+Silent:root:This should only be seen at the 'Silent' logging level (or lower)
+-- log_test1 end ---------------------------------------------------
+-- log_test2 begin ---------------------------------------------------
+-- logging at DEBUG, nothing should be seen yet --
+-- logging at INFO, nothing should be seen yet --
+-- logging at WARN, 3 messages should be seen --
+DEBUG:root:Debug message
+INFO:root:Info message
+WARN:root:Warn message
+-- logging 0 at INFO, messages should be seen every 10 events --
+-- logging 1 at INFO, messages should be seen every 10 events --
+-- logging 2 at INFO, messages should be seen every 10 events --
+-- logging 3 at INFO, messages should be seen every 10 events --
+-- logging 4 at INFO, messages should be seen every 10 events --
+-- logging 5 at INFO, messages should be seen every 10 events --
+-- logging 6 at INFO, messages should be seen every 10 events --
+-- logging 7 at INFO, messages should be seen every 10 events --
+-- logging 8 at INFO, messages should be seen every 10 events --
+-- logging 9 at INFO, messages should be seen every 10 events --
+INFO:root:Info index = 0
+INFO:root:Info index = 1
+INFO:root:Info index = 2
+INFO:root:Info index = 3
+INFO:root:Info index = 4
+INFO:root:Info index = 5
+INFO:root:Info index = 6
+INFO:root:Info index = 7
+INFO:root:Info index = 8
+INFO:root:Info index = 9
+-- logging 10 at INFO, messages should be seen every 10 events --
+-- logging 11 at INFO, messages should be seen every 10 events --
+-- logging 12 at INFO, messages should be seen every 10 events --
+-- logging 13 at INFO, messages should be seen every 10 events --
+-- logging 14 at INFO, messages should be seen every 10 events --
+-- logging 15 at INFO, messages should be seen every 10 events --
+-- logging 16 at INFO, messages should be seen every 10 events --
+-- logging 17 at INFO, messages should be seen every 10 events --
+-- logging 18 at INFO, messages should be seen every 10 events --
+-- logging 19 at INFO, messages should be seen every 10 events --
+INFO:root:Info index = 10
+INFO:root:Info index = 11
+INFO:root:Info index = 12
+INFO:root:Info index = 13
+INFO:root:Info index = 14
+INFO:root:Info index = 15
+INFO:root:Info index = 16
+INFO:root:Info index = 17
+INFO:root:Info index = 18
+INFO:root:Info index = 19
+-- logging 20 at INFO, messages should be seen every 10 events --
+-- logging 21 at INFO, messages should be seen every 10 events --
+-- logging 22 at INFO, messages should be seen every 10 events --
+-- logging 23 at INFO, messages should be seen every 10 events --
+-- logging 24 at INFO, messages should be seen every 10 events --
+-- logging 25 at INFO, messages should be seen every 10 events --
+-- logging 26 at INFO, messages should be seen every 10 events --
+-- logging 27 at INFO, messages should be seen every 10 events --
+-- logging 28 at INFO, messages should be seen every 10 events --
+-- logging 29 at INFO, messages should be seen every 10 events --
+INFO:root:Info index = 20
+INFO:root:Info index = 21
+INFO:root:Info index = 22
+INFO:root:Info index = 23
+INFO:root:Info index = 24
+INFO:root:Info index = 25
+INFO:root:Info index = 26
+INFO:root:Info index = 27
+INFO:root:Info index = 28
+INFO:root:Info index = 29
+-- logging 30 at INFO, messages should be seen every 10 events --
+-- logging 31 at INFO, messages should be seen every 10 events --
+-- logging 32 at INFO, messages should be seen every 10 events --
+-- logging 33 at INFO, messages should be seen every 10 events --
+-- logging 34 at INFO, messages should be seen every 10 events --
+-- logging 35 at INFO, messages should be seen every 10 events --
+-- logging 36 at INFO, messages should be seen every 10 events --
+-- logging 37 at INFO, messages should be seen every 10 events --
+-- logging 38 at INFO, messages should be seen every 10 events --
+-- logging 39 at INFO, messages should be seen every 10 events --
+INFO:root:Info index = 30
+INFO:root:Info index = 31
+INFO:root:Info index = 32
+INFO:root:Info index = 33
+INFO:root:Info index = 34
+INFO:root:Info index = 35
+INFO:root:Info index = 36
+INFO:root:Info index = 37
+INFO:root:Info index = 38
+INFO:root:Info index = 39
+-- logging 40 at INFO, messages should be seen every 10 events --
+-- logging 41 at INFO, messages should be seen every 10 events --
+-- logging 42 at INFO, messages should be seen every 10 events --
+-- logging 43 at INFO, messages should be seen every 10 events --
+-- logging 44 at INFO, messages should be seen every 10 events --
+-- logging 45 at INFO, messages should be seen every 10 events --
+-- logging 46 at INFO, messages should be seen every 10 events --
+-- logging 47 at INFO, messages should be seen every 10 events --
+-- logging 48 at INFO, messages should be seen every 10 events --
+-- logging 49 at INFO, messages should be seen every 10 events --
+INFO:root:Info index = 40
+INFO:root:Info index = 41
+INFO:root:Info index = 42
+INFO:root:Info index = 43
+INFO:root:Info index = 44
+INFO:root:Info index = 45
+INFO:root:Info index = 46
+INFO:root:Info index = 47
+INFO:root:Info index = 48
+INFO:root:Info index = 49
+-- logging 50 at INFO, messages should be seen every 10 events --
+-- logging 51 at INFO, messages should be seen every 10 events --
+-- logging 52 at INFO, messages should be seen every 10 events --
+-- logging 53 at INFO, messages should be seen every 10 events --
+-- logging 54 at INFO, messages should be seen every 10 events --
+-- logging 55 at INFO, messages should be seen every 10 events --
+-- logging 56 at INFO, messages should be seen every 10 events --
+-- logging 57 at INFO, messages should be seen every 10 events --
+-- logging 58 at INFO, messages should be seen every 10 events --
+-- logging 59 at INFO, messages should be seen every 10 events --
+INFO:root:Info index = 50
+INFO:root:Info index = 51
+INFO:root:Info index = 52
+INFO:root:Info index = 53
+INFO:root:Info index = 54
+INFO:root:Info index = 55
+INFO:root:Info index = 56
+INFO:root:Info index = 57
+INFO:root:Info index = 58
+INFO:root:Info index = 59
+-- logging 60 at INFO, messages should be seen every 10 events --
+-- logging 61 at INFO, messages should be seen every 10 events --
+-- logging 62 at INFO, messages should be seen every 10 events --
+-- logging 63 at INFO, messages should be seen every 10 events --
+-- logging 64 at INFO, messages should be seen every 10 events --
+-- logging 65 at INFO, messages should be seen every 10 events --
+-- logging 66 at INFO, messages should be seen every 10 events --
+-- logging 67 at INFO, messages should be seen every 10 events --
+-- logging 68 at INFO, messages should be seen every 10 events --
+-- logging 69 at INFO, messages should be seen every 10 events --
+INFO:root:Info index = 60
+INFO:root:Info index = 61
+INFO:root:Info index = 62
+INFO:root:Info index = 63
+INFO:root:Info index = 64
+INFO:root:Info index = 65
+INFO:root:Info index = 66
+INFO:root:Info index = 67
+INFO:root:Info index = 68
+INFO:root:Info index = 69
+-- logging 70 at INFO, messages should be seen every 10 events --
+-- logging 71 at INFO, messages should be seen every 10 events --
+-- logging 72 at INFO, messages should be seen every 10 events --
+-- logging 73 at INFO, messages should be seen every 10 events --
+-- logging 74 at INFO, messages should be seen every 10 events --
+-- logging 75 at INFO, messages should be seen every 10 events --
+-- logging 76 at INFO, messages should be seen every 10 events --
+-- logging 77 at INFO, messages should be seen every 10 events --
+-- logging 78 at INFO, messages should be seen every 10 events --
+-- logging 79 at INFO, messages should be seen every 10 events --
+INFO:root:Info index = 70
+INFO:root:Info index = 71
+INFO:root:Info index = 72
+INFO:root:Info index = 73
+INFO:root:Info index = 74
+INFO:root:Info index = 75
+INFO:root:Info index = 76
+INFO:root:Info index = 77
+INFO:root:Info index = 78
+INFO:root:Info index = 79
+-- logging 80 at INFO, messages should be seen every 10 events --
+-- logging 81 at INFO, messages should be seen every 10 events --
+-- logging 82 at INFO, messages should be seen every 10 events --
+-- logging 83 at INFO, messages should be seen every 10 events --
+-- logging 84 at INFO, messages should be seen every 10 events --
+-- logging 85 at INFO, messages should be seen every 10 events --
+-- logging 86 at INFO, messages should be seen every 10 events --
+-- logging 87 at INFO, messages should be seen every 10 events --
+-- logging 88 at INFO, messages should be seen every 10 events --
+-- logging 89 at INFO, messages should be seen every 10 events --
+INFO:root:Info index = 80
+INFO:root:Info index = 81
+INFO:root:Info index = 82
+INFO:root:Info index = 83
+INFO:root:Info index = 84
+INFO:root:Info index = 85
+INFO:root:Info index = 86
+INFO:root:Info index = 87
+INFO:root:Info index = 88
+INFO:root:Info index = 89
+-- logging 90 at INFO, messages should be seen every 10 events --
+-- logging 91 at INFO, messages should be seen every 10 events --
+-- logging 92 at INFO, messages should be seen every 10 events --
+-- logging 93 at INFO, messages should be seen every 10 events --
+-- logging 94 at INFO, messages should be seen every 10 events --
+-- logging 95 at INFO, messages should be seen every 10 events --
+-- logging 96 at INFO, messages should be seen every 10 events --
+-- logging 97 at INFO, messages should be seen every 10 events --
+-- logging 98 at INFO, messages should be seen every 10 events --
+-- logging 99 at INFO, messages should be seen every 10 events --
+INFO:root:Info index = 90
+INFO:root:Info index = 91
+INFO:root:Info index = 92
+INFO:root:Info index = 93
+INFO:root:Info index = 94
+INFO:root:Info index = 95
+INFO:root:Info index = 96
+INFO:root:Info index = 97
+INFO:root:Info index = 98
+INFO:root:Info index = 99
+-- logging 100 at INFO, messages should be seen every 10 events --
+-- logging 101 at INFO, messages should be seen every 10 events --
+INFO:root:Info index = 100
+INFO:root:Info index = 101
+-- log_test2 end ---------------------------------------------------
+-- log_test3 begin ---------------------------------------------------
+Unfiltered...
+INFO:a:Info 1
+INFO:a.b:Info 2
+INFO:a.c:Info 3
+INFO:a.b.c:Info 4
+INFO:a.b.c.d:Info 5
+INFO:a.bb.c:Info 6
+INFO:b:Info 7
+INFO:b.a:Info 8
+INFO:c.a.b:Info 9
+INFO:a.bb:Info 10
+Filtered with 'a.b'...
+INFO:a.b:Info 2
+INFO:a.b.c:Info 4
+INFO:a.b.c.d:Info 5
+-- log_test3 end ---------------------------------------------------
+-- logrecv output begin ---------------------------------------------------
+ERR -> CRITICAL: Message 0 (via logrecv.tcp.ERR)
+ERR -> ERROR: Message 1 (via logrecv.tcp.ERR)
+INF -> CRITICAL: Message 2 (via logrecv.tcp.INF)
+INF -> ERROR: Message 3 (via logrecv.tcp.INF)
+INF -> WARN: Message 4 (via logrecv.tcp.INF)
+INF -> INFO: Message 5 (via logrecv.tcp.INF)
+INF.UNDEF -> CRITICAL: Message 6 (via logrecv.tcp.INF.UNDEF)
+INF.UNDEF -> ERROR: Message 7 (via logrecv.tcp.INF.UNDEF)
+INF.UNDEF -> WARN: Message 8 (via logrecv.tcp.INF.UNDEF)
+INF.UNDEF -> INFO: Message 9 (via logrecv.tcp.INF.UNDEF)
+INF.ERR -> CRITICAL: Message 10 (via logrecv.tcp.INF.ERR)
+INF.ERR -> ERROR: Message 11 (via logrecv.tcp.INF.ERR)
+INF.ERR.UNDEF -> CRITICAL: Message 12 (via logrecv.tcp.INF.ERR.UNDEF)
+INF.ERR.UNDEF -> ERROR: Message 13 (via logrecv.tcp.INF.ERR.UNDEF)
+DEB -> CRITICAL: Message 14 (via logrecv.tcp.DEB)
+DEB -> ERROR: Message 15 (via logrecv.tcp.DEB)
+DEB -> WARN: Message 16 (via logrecv.tcp.DEB)
+DEB -> INFO: Message 17 (via logrecv.tcp.DEB)
+DEB -> DEBUG: Message 18 (via logrecv.tcp.DEB)
+UNDEF -> CRITICAL: Message 19 (via logrecv.tcp.UNDEF)
+UNDEF -> ERROR: Message 20 (via logrecv.tcp.UNDEF)
+UNDEF -> WARN: Message 21 (via logrecv.tcp.UNDEF)
+UNDEF -> INFO: Message 22 (via logrecv.tcp.UNDEF)
+INF.BADPARENT.UNDEF -> CRITICAL: Message 23 (via logrecv.tcp.INF.BADPARENT.UNDEF)
+INF.BADPARENT -> CRITICAL: Message 24 (via logrecv.tcp.INF.BADPARENT)
+INF -> INFO: Messages should bear numbers 0 through 24. (via logrecv.tcp.INF)
+-- logrecv output end ---------------------------------------------------
diff --git a/Lib/test/test_logging.py b/Lib/test/test_logging.py
new file mode 100644
index 0000000..360d3ac
--- /dev/null
+++ b/Lib/test/test_logging.py
@@ -0,0 +1,459 @@
+#!/usr/bin/env python
+#
+# Copyright 2001-2002 by Vinay Sajip. All Rights Reserved.
+#
+# Permission to use, copy, modify, and distribute this software and its
+# documentation for any purpose and without fee is hereby granted,
+# provided that the above copyright notice appear in all copies and that
+# both that copyright notice and this permission notice appear in
+# supporting documentation, and that the name of Vinay Sajip
+# not be used in advertising or publicity pertaining to distribution
+# of the software without specific, written prior permission.
+# VINAY SAJIP DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
+# ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL
+# VINAY SAJIP BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
+# ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER
+# IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT
+# OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+#
+# This file is part of the Python logging distribution. See
+# http://www.red-dove.com/python_logging.html
+#
+"""Test harness for the logging module. Run all tests.
+
+Copyright (C) 2001-2002 Vinay Sajip. All Rights Reserved.
+"""
+
+from select import select
+import os, sys, string, struct, types, cPickle, cStringIO
+import socket, threading, time, locale
+import logging, logging.handlers, logging.config
+
+locale.setlocale(locale.LC_ALL, '')
+
+BANNER = "-- %-10s %-6s ---------------------------------------------------\n"
+
+#----------------------------------------------------------------------------
+# Log receiver
+#----------------------------------------------------------------------------
+
+TIMEOUT = 10
+
+from SocketServer import ThreadingTCPServer, StreamRequestHandler
+
+class LogRecordStreamHandler(StreamRequestHandler):
+ """
+ Handler for a streaming logging request. It basically logs the record
+ using whatever logging policy is configured locally.
+ """
+
+ def handle(self):
+ """
+ Handle multiple requests - each expected to be a 4-byte length,
+ followed by the LogRecord in pickle format. Logs the record
+ according to whatever policy is configured locally.
+ """
+ while 1:
+ try:
+ chunk = self.connection.recv(4)
+ if len(chunk) < 4:
+ break
+ slen = struct.unpack(">L", chunk)[0]
+ #print slen
+ chunk = self.connection.recv(slen)
+ while len(chunk) < slen:
+ chunk = chunk + self.connection.recv(slen - len(chunk))
+ obj = self.unPickle(chunk)
+ record = logging.LogRecord(None, None, "", 0, "", (), None)
+ record.__dict__.update(obj)
+ self.handleLogRecord(record)
+ except:
+ raise
+
+ def unPickle(self, data):
+ return cPickle.loads(data)
+
+ def handleLogRecord(self, record):
+ logname = "logrecv.tcp." + record.name
+ record.msg = record.msg + " (via " + logname + ")"
+ logger = logging.getLogger(logname)
+ logger.handle(record)
+
+class LogRecordSocketReceiver(ThreadingTCPServer):
+ """
+ A simple-minded TCP socket-based logging receiver suitable for test
+ purposes.
+ """
+
+ allow_reuse_address = 1
+
+ def __init__(self, host='localhost',
+ port=logging.handlers.DEFAULT_TCP_LOGGING_PORT,
+ handler=LogRecordStreamHandler):
+ ThreadingTCPServer.__init__(self, (host, port), handler)
+ self.abort = 0
+ self.timeout = 1
+
+ def serve_until_stopped(self):
+ abort = 0
+ while not abort:
+ rd, wr, ex = select([self.socket.fileno()],
+ [], [],
+ self.timeout)
+ if rd:
+ self.handle_request()
+ abort = self.abort
+
+def runTCP(tcpserver):
+ tcpserver.serve_until_stopped()
+
+#----------------------------------------------------------------------------
+# Test 0
+#----------------------------------------------------------------------------
+
+msgcount = 0
+
+def nextmessage():
+ global msgcount
+ rv = "Message %d" % msgcount
+ msgcount = msgcount + 1
+ return rv
+
+def test0():
+ ERR = logging.getLogger("ERR")
+ ERR.setLevel(logging.ERROR)
+ INF = logging.getLogger("INF")
+ INF.setLevel(logging.INFO)
+ INF_ERR = logging.getLogger("INF.ERR")
+ INF_ERR.setLevel(logging.ERROR)
+ DEB = logging.getLogger("DEB")
+ DEB.setLevel(logging.DEBUG)
+
+ INF_UNDEF = logging.getLogger("INF.UNDEF")
+ INF_ERR_UNDEF = logging.getLogger("INF.ERR.UNDEF")
+ UNDEF = logging.getLogger("UNDEF")
+
+ GRANDCHILD = logging.getLogger("INF.BADPARENT.UNDEF")
+ CHILD = logging.getLogger("INF.BADPARENT")
+
+ #These should log
+ ERR.log(logging.FATAL, nextmessage())
+ ERR.error(nextmessage())
+
+ INF.log(logging.FATAL, nextmessage())
+ INF.error(nextmessage())
+ INF.warn(nextmessage())
+ INF.info(nextmessage())
+
+ INF_UNDEF.log(logging.FATAL, nextmessage())
+ INF_UNDEF.error(nextmessage())
+ INF_UNDEF.warn (nextmessage())
+ INF_UNDEF.info (nextmessage())
+
+ INF_ERR.log(logging.FATAL, nextmessage())
+ INF_ERR.error(nextmessage())
+
+ INF_ERR_UNDEF.log(logging.FATAL, nextmessage())
+ INF_ERR_UNDEF.error(nextmessage())
+
+ DEB.log(logging.FATAL, nextmessage())
+ DEB.error(nextmessage())
+ DEB.warn (nextmessage())
+ DEB.info (nextmessage())
+ DEB.debug(nextmessage())
+
+ UNDEF.log(logging.FATAL, nextmessage())
+ UNDEF.error(nextmessage())
+ UNDEF.warn (nextmessage())
+ UNDEF.info (nextmessage())
+
+ GRANDCHILD.log(logging.FATAL, nextmessage())
+ CHILD.log(logging.FATAL, nextmessage())
+
+ #These should not log
+ ERR.warn(nextmessage())
+ ERR.info(nextmessage())
+ ERR.debug(nextmessage())
+
+ INF.debug(nextmessage())
+ INF_UNDEF.debug(nextmessage())
+
+ INF_ERR.warn(nextmessage())
+ INF_ERR.info(nextmessage())
+ INF_ERR.debug(nextmessage())
+ INF_ERR_UNDEF.warn(nextmessage())
+ INF_ERR_UNDEF.info(nextmessage())
+ INF_ERR_UNDEF.debug(nextmessage())
+
+ INF.info("Messages should bear numbers 0 through 24.")
+
+#----------------------------------------------------------------------------
+# Test 1
+#----------------------------------------------------------------------------
+
+#
+# First, we define our levels. There can be as many as you want - the only
+# limitations are that they should be integers, the lowest should be > 0 and
+# larger values mean less information being logged. If you need specific
+# level values which do not fit into these limitations, you can use a
+# mapping dictionary to convert between your application levels and the
+# logging system.
+#
+SILENT = 10
+TACITURN = 9
+TERSE = 8
+EFFUSIVE = 7
+SOCIABLE = 6
+VERBOSE = 5
+TALKATIVE = 4
+GARRULOUS = 3
+CHATTERBOX = 2
+BORING = 1
+
+LEVEL_RANGE = range(BORING, SILENT + 1)
+
+#
+# Next, we define names for our levels. You don't need to do this - in which
+# case the system will use "Level n" to denote the text for the level.
+#
+my_logging_levels = {
+ SILENT : 'Silent',
+ TACITURN : 'Taciturn',
+ TERSE : 'Terse',
+ EFFUSIVE : 'Effusive',
+ SOCIABLE : 'Sociable',
+ VERBOSE : 'Verbose',
+ TALKATIVE : 'Talkative',
+ GARRULOUS : 'Garrulous',
+ CHATTERBOX : 'Chatterbox',
+ BORING : 'Boring',
+}
+
+#
+# Now, to demonstrate filtering: suppose for some perverse reason we only
+# want to print out all except GARRULOUS messages. Let's create a filter for
+# this purpose...
+#
+class SpecificLevelFilter(logging.Filter):
+ def __init__(self, lvl):
+ self.level = lvl
+
+ def filter(self, record):
+ return self.level != record.levelno
+
+class GarrulousFilter(SpecificLevelFilter):
+ def __init__(self):
+ SpecificLevelFilter.__init__(self, GARRULOUS)
+
+#
+# Now, let's demonstrate filtering at the logger. This time, use a filter
+# which excludes SOCIABLE and TACITURN messages. Note that GARRULOUS events
+# are still excluded.
+#
+class VerySpecificFilter(logging.Filter):
+ def filter(self, record):
+ return record.levelno not in [SOCIABLE, TACITURN]
+
+def message(s):
+ sys.stdout.write("%s\n" % s)
+
+SHOULD1 = "This should only be seen at the '%s' logging level (or lower)"
+
+def test1():
+#
+# Now, tell the logging system to associate names with our levels.
+#
+ for lvl in my_logging_levels.keys():
+ logging.addLevelName(lvl, my_logging_levels[lvl])
+
+#
+# Now, define a test function which logs an event at each of our levels.
+#
+
+ def doLog(log):
+ for lvl in LEVEL_RANGE:
+ log.log(lvl, SHOULD1, logging.getLevelName(lvl))
+
+ log = logging.getLogger("")
+ hdlr = log.handlers[0]
+#
+# Set the logging level to each different value and call the utility
+# function to log events.
+# In the output, you should see that each time round the loop, the number of
+# logging events which are actually output decreases.
+#
+ for lvl in LEVEL_RANGE:
+ message("-- setting logging level to '%s' -----" %
+ logging.getLevelName(lvl))
+ log.setLevel(lvl)
+ doLog(log)
+ #
+ # Now, we demonstrate level filtering at the handler level. Tell the
+ # handler defined above to filter at level 'SOCIABLE', and repeat the
+ # above loop. Compare the output from the two runs.
+ #
+ hdlr.setLevel(SOCIABLE)
+ message("-- Filtering at handler level to SOCIABLE --")
+ for lvl in LEVEL_RANGE:
+ message("-- setting logging level to '%s' -----" %
+ logging.getLevelName(lvl))
+ log.setLevel(lvl)
+ doLog(log)
+
+ hdlr.setLevel(0) #turn off level filtering at the handler
+
+ garr = GarrulousFilter()
+ hdlr.addFilter(garr)
+ message("-- Filtering using GARRULOUS filter --")
+ for lvl in LEVEL_RANGE:
+ message("-- setting logging level to '%s' -----" %
+ logging.getLevelName(lvl))
+ log.setLevel(lvl)
+ doLog(log)
+ spec = VerySpecificFilter()
+ log.addFilter(spec)
+ message("-- Filtering using specific filter for SOCIABLE, TACITURN --")
+ for lvl in LEVEL_RANGE:
+ message("-- setting logging level to '%s' -----" %
+ logging.getLevelName(lvl))
+ log.setLevel(lvl)
+ doLog(log)
+
+ log.removeFilter(spec)
+ hdlr.removeFilter(garr)
+ #Undo the one level which clashes...for regression tests
+ logging.addLevelName(logging.DEBUG, "DEBUG")
+
+#----------------------------------------------------------------------------
+# Test 2
+#----------------------------------------------------------------------------
+
+MSG = "-- logging %d at INFO, messages should be seen every 10 events --"
+def test2():
+ logger = logging.getLogger("")
+ sh = logger.handlers[0]
+ logger.removeHandler(sh)
+ mh = logging.handlers.MemoryHandler(10,logging.WARN, sh)
+ logger.setLevel(logging.DEBUG)
+ logger.addHandler(mh)
+ message("-- logging at DEBUG, nothing should be seen yet --")
+ logger.debug("Debug message")
+ message("-- logging at INFO, nothing should be seen yet --")
+ logger.info("Info message")
+ message("-- logging at WARN, 3 messages should be seen --")
+ logger.warn("Warn message")
+ for i in xrange(102):
+ message(MSG % i)
+ logger.info("Info index = %d", i)
+ mh.close()
+ logger.removeHandler(mh)
+ logger.addHandler(sh)
+
+#----------------------------------------------------------------------------
+# Test 3
+#----------------------------------------------------------------------------
+
+FILTER = "a.b"
+
+def doLog3():
+ logging.getLogger("a").info("Info 1")
+ logging.getLogger("a.b").info("Info 2")
+ logging.getLogger("a.c").info("Info 3")
+ logging.getLogger("a.b.c").info("Info 4")
+ logging.getLogger("a.b.c.d").info("Info 5")
+ logging.getLogger("a.bb.c").info("Info 6")
+ logging.getLogger("b").info("Info 7")
+ logging.getLogger("b.a").info("Info 8")
+ logging.getLogger("c.a.b").info("Info 9")
+ logging.getLogger("a.bb").info("Info 10")
+
+def test3():
+ root = logging.getLogger()
+ root.setLevel(logging.DEBUG)
+ hand = root.handlers[0]
+ message("Unfiltered...")
+ doLog3()
+ message("Filtered with '%s'..." % FILTER)
+ filt = logging.Filter(FILTER)
+ hand.addFilter(filt)
+ doLog3()
+ hand.removeFilter(filt)
+
+#----------------------------------------------------------------------------
+# Test Harness
+#----------------------------------------------------------------------------
+def banner(nm, typ):
+ sep = BANNER % (nm, typ)
+ sys.stdout.write(sep)
+ sys.stdout.flush()
+
+def test_main():
+ rootLogger = logging.getLogger("")
+ rootLogger.setLevel(logging.DEBUG)
+ hdlr = logging.StreamHandler(sys.stdout)
+ fmt = logging.Formatter(logging.BASIC_FORMAT)
+ hdlr.setFormatter(fmt)
+ rootLogger.addHandler(hdlr)
+
+ #Set up a handler such that all events are sent via a socket to the log
+ #receiver (logrecv).
+ #The handler will only be added to the rootLogger for some of the tests
+ hdlr = logging.handlers.SocketHandler('localhost',
+ logging.handlers.DEFAULT_TCP_LOGGING_PORT)
+
+ #Configure the logger for logrecv so events do not propagate beyond it.
+ #The sockLogger output is buffered in memory until the end of the test,
+ #and printed at the end.
+ sockOut = cStringIO.StringIO()
+ sockLogger = logging.getLogger("logrecv")
+ sockLogger.setLevel(logging.DEBUG)
+ sockhdlr = logging.StreamHandler(sockOut)
+ sockhdlr.setFormatter(logging.Formatter(
+ "%(name)s -> %(levelname)s: %(message)s"))
+ sockLogger.addHandler(sockhdlr)
+ sockLogger.propagate = 0
+
+ #Set up servers
+ threads = []
+ tcpserver = LogRecordSocketReceiver()
+ sys.stdout.write("About to start TCP server...\n")
+ threads.append(threading.Thread(target=runTCP, args=(tcpserver,)))
+
+ for thread in threads:
+ thread.start()
+ try:
+ banner("log_test0", "begin")
+
+ rootLogger.addHandler(hdlr)
+ test0()
+ rootLogger.removeHandler(hdlr)
+
+ banner("log_test0", "end")
+
+ banner("log_test1", "begin")
+ test1()
+ banner("log_test1", "end")
+
+ banner("log_test2", "begin")
+ test2()
+ banner("log_test2", "end")
+
+ banner("log_test3", "begin")
+ test3()
+ banner("log_test3", "end")
+
+ banner("logrecv output", "begin")
+ sys.stdout.write(sockOut.getvalue())
+ sockOut.close()
+ banner("logrecv output", "end")
+
+ finally:
+ #shut down server
+ tcpserver.abort = 1
+ for thread in threads:
+ thread.join()
+
+if __name__ == "__main__":
+ sys.stdout.write("test_logging\n")
+ test_main()
+ sys.stdout.flush()