Neal Norwitz | b4a2df0 | 2003-01-02 14:56:39 +0000 | [diff] [blame] | 1 | #!/usr/bin/env python |
Neal Norwitz | b4a2df0 | 2003-01-02 14:56:39 +0000 | [diff] [blame] | 2 | """ |
Brett Cannon | f9db8a3 | 2008-02-17 01:59:18 +0000 | [diff] [blame] | 3 | Test 0 |
| 4 | ====== |
Neal Norwitz | b4a2df0 | 2003-01-02 14:56:39 +0000 | [diff] [blame] | 5 | |
Brett Cannon | f9db8a3 | 2008-02-17 01:59:18 +0000 | [diff] [blame] | 6 | Some preliminaries: |
| 7 | >>> import sys |
| 8 | >>> import logging |
| 9 | >>> def nextmessage(): |
| 10 | ... global msgcount |
| 11 | ... rv = "Message %d" % msgcount |
| 12 | ... msgcount = msgcount + 1 |
| 13 | ... return rv |
| 14 | |
| 15 | Set a few variables, then go through the logger autoconfig and set the default threshold. |
| 16 | >>> msgcount = 0 |
| 17 | >>> FINISH_UP = "Finish up, it's closing time. Messages should bear numbers 0 through 24." |
| 18 | >>> logging.basicConfig(stream=sys.stdout) |
| 19 | >>> rootLogger = logging.getLogger("") |
| 20 | >>> rootLogger.setLevel(logging.DEBUG) |
| 21 | |
| 22 | Now, create a bunch of loggers, and set their thresholds. |
| 23 | >>> ERR = logging.getLogger("ERR0") |
| 24 | >>> ERR.setLevel(logging.ERROR) |
| 25 | >>> INF = logging.getLogger("INFO0") |
| 26 | >>> INF.setLevel(logging.INFO) |
| 27 | >>> INF_ERR = logging.getLogger("INFO0.ERR") |
| 28 | >>> INF_ERR.setLevel(logging.ERROR) |
| 29 | >>> DEB = logging.getLogger("DEB0") |
| 30 | >>> DEB.setLevel(logging.DEBUG) |
| 31 | >>> INF_UNDEF = logging.getLogger("INFO0.UNDEF") |
| 32 | >>> INF_ERR_UNDEF = logging.getLogger("INFO0.ERR.UNDEF") |
| 33 | >>> UNDEF = logging.getLogger("UNDEF0") |
| 34 | >>> GRANDCHILD = logging.getLogger("INFO0.BADPARENT.UNDEF") |
| 35 | >>> CHILD = logging.getLogger("INFO0.BADPARENT") |
| 36 | |
| 37 | |
| 38 | And finally, run all the tests. |
| 39 | |
| 40 | >>> ERR.log(logging.FATAL, nextmessage()) |
| 41 | CRITICAL:ERR0:Message 0 |
| 42 | |
| 43 | >>> ERR.error(nextmessage()) |
| 44 | ERROR:ERR0:Message 1 |
| 45 | |
| 46 | >>> INF.log(logging.FATAL, nextmessage()) |
| 47 | CRITICAL:INFO0:Message 2 |
| 48 | |
| 49 | >>> INF.error(nextmessage()) |
| 50 | ERROR:INFO0:Message 3 |
| 51 | |
| 52 | >>> INF.warn(nextmessage()) |
| 53 | WARNING:INFO0:Message 4 |
| 54 | |
| 55 | >>> INF.info(nextmessage()) |
| 56 | INFO:INFO0:Message 5 |
| 57 | |
| 58 | >>> INF_UNDEF.log(logging.FATAL, nextmessage()) |
| 59 | CRITICAL:INFO0.UNDEF:Message 6 |
| 60 | |
| 61 | >>> INF_UNDEF.error(nextmessage()) |
| 62 | ERROR:INFO0.UNDEF:Message 7 |
| 63 | |
| 64 | >>> INF_UNDEF.warn (nextmessage()) |
| 65 | WARNING:INFO0.UNDEF:Message 8 |
| 66 | |
| 67 | >>> INF_UNDEF.info (nextmessage()) |
| 68 | INFO:INFO0.UNDEF:Message 9 |
| 69 | |
| 70 | >>> INF_ERR.log(logging.FATAL, nextmessage()) |
| 71 | CRITICAL:INFO0.ERR:Message 10 |
| 72 | |
| 73 | >>> INF_ERR.error(nextmessage()) |
| 74 | ERROR:INFO0.ERR:Message 11 |
| 75 | |
| 76 | >>> INF_ERR_UNDEF.log(logging.FATAL, nextmessage()) |
| 77 | CRITICAL:INFO0.ERR.UNDEF:Message 12 |
| 78 | |
| 79 | >>> INF_ERR_UNDEF.error(nextmessage()) |
| 80 | ERROR:INFO0.ERR.UNDEF:Message 13 |
| 81 | |
| 82 | >>> DEB.log(logging.FATAL, nextmessage()) |
| 83 | CRITICAL:DEB0:Message 14 |
| 84 | |
| 85 | >>> DEB.error(nextmessage()) |
| 86 | ERROR:DEB0:Message 15 |
| 87 | |
| 88 | >>> DEB.warn (nextmessage()) |
| 89 | WARNING:DEB0:Message 16 |
| 90 | |
| 91 | >>> DEB.info (nextmessage()) |
| 92 | INFO:DEB0:Message 17 |
| 93 | |
| 94 | >>> DEB.debug(nextmessage()) |
| 95 | DEBUG:DEB0:Message 18 |
| 96 | |
| 97 | >>> UNDEF.log(logging.FATAL, nextmessage()) |
| 98 | CRITICAL:UNDEF0:Message 19 |
| 99 | |
| 100 | >>> UNDEF.error(nextmessage()) |
| 101 | ERROR:UNDEF0:Message 20 |
| 102 | |
| 103 | >>> UNDEF.warn (nextmessage()) |
| 104 | WARNING:UNDEF0:Message 21 |
| 105 | |
| 106 | >>> UNDEF.info (nextmessage()) |
| 107 | INFO:UNDEF0:Message 22 |
| 108 | |
| 109 | >>> GRANDCHILD.log(logging.FATAL, nextmessage()) |
| 110 | CRITICAL:INFO0.BADPARENT.UNDEF:Message 23 |
| 111 | |
| 112 | >>> CHILD.log(logging.FATAL, nextmessage()) |
| 113 | CRITICAL:INFO0.BADPARENT:Message 24 |
| 114 | |
| 115 | These should not log: |
| 116 | |
| 117 | >>> ERR.warn(nextmessage()) |
| 118 | |
| 119 | >>> ERR.info(nextmessage()) |
| 120 | |
| 121 | >>> ERR.debug(nextmessage()) |
| 122 | |
| 123 | >>> INF.debug(nextmessage()) |
| 124 | |
| 125 | >>> INF_UNDEF.debug(nextmessage()) |
| 126 | |
| 127 | >>> INF_ERR.warn(nextmessage()) |
| 128 | |
| 129 | >>> INF_ERR.info(nextmessage()) |
| 130 | |
| 131 | >>> INF_ERR.debug(nextmessage()) |
| 132 | |
| 133 | >>> INF_ERR_UNDEF.warn(nextmessage()) |
| 134 | |
| 135 | >>> INF_ERR_UNDEF.info(nextmessage()) |
| 136 | |
| 137 | >>> INF_ERR_UNDEF.debug(nextmessage()) |
| 138 | |
| 139 | >>> INF.info(FINISH_UP) |
| 140 | INFO:INFO0:Finish up, it's closing time. Messages should bear numbers 0 through 24. |
| 141 | |
| 142 | Test 1 |
| 143 | ====== |
| 144 | |
| 145 | >>> import sys, logging |
| 146 | >>> logging.basicConfig(stream=sys.stdout) |
| 147 | |
| 148 | First, we define our levels. There can be as many as you want - the only |
| 149 | limitations are that they should be integers, the lowest should be > 0 and |
| 150 | larger values mean less information being logged. If you need specific |
| 151 | level values which do not fit into these limitations, you can use a |
| 152 | mapping dictionary to convert between your application levels and the |
| 153 | logging system. |
| 154 | |
| 155 | >>> SILENT = 10 |
| 156 | >>> TACITURN = 9 |
| 157 | >>> TERSE = 8 |
| 158 | >>> EFFUSIVE = 7 |
| 159 | >>> SOCIABLE = 6 |
| 160 | >>> VERBOSE = 5 |
| 161 | >>> TALKATIVE = 4 |
| 162 | >>> GARRULOUS = 3 |
| 163 | >>> CHATTERBOX = 2 |
| 164 | >>> BORING = 1 |
| 165 | >>> LEVEL_RANGE = range(BORING, SILENT + 1) |
| 166 | |
| 167 | |
| 168 | Next, we define names for our levels. You don't need to do this - in which |
| 169 | case the system will use "Level n" to denote the text for the level. |
| 170 | ' |
| 171 | |
| 172 | |
| 173 | >>> my_logging_levels = { |
| 174 | ... SILENT : 'SILENT', |
| 175 | ... TACITURN : 'TACITURN', |
| 176 | ... TERSE : 'TERSE', |
| 177 | ... EFFUSIVE : 'EFFUSIVE', |
| 178 | ... SOCIABLE : 'SOCIABLE', |
| 179 | ... VERBOSE : 'VERBOSE', |
| 180 | ... TALKATIVE : 'TALKATIVE', |
| 181 | ... GARRULOUS : 'GARRULOUS', |
| 182 | ... CHATTERBOX : 'CHATTERBOX', |
| 183 | ... BORING : 'BORING', |
| 184 | ... } |
| 185 | |
| 186 | |
| 187 | Now, to demonstrate filtering: suppose for some perverse reason we only |
| 188 | want to print out all except GARRULOUS messages. We create a filter for |
| 189 | this purpose... |
| 190 | |
| 191 | >>> class SpecificLevelFilter(logging.Filter): |
| 192 | ... def __init__(self, lvl): |
| 193 | ... self.level = lvl |
| 194 | ... |
| 195 | ... def filter(self, record): |
| 196 | ... return self.level != record.levelno |
| 197 | |
| 198 | >>> class GarrulousFilter(SpecificLevelFilter): |
| 199 | ... def __init__(self): |
| 200 | ... SpecificLevelFilter.__init__(self, GARRULOUS) |
| 201 | |
| 202 | |
| 203 | Now, demonstrate filtering at the logger. This time, use a filter |
| 204 | which excludes SOCIABLE and TACITURN messages. Note that GARRULOUS events |
| 205 | are still excluded. |
| 206 | |
| 207 | |
| 208 | >>> class VerySpecificFilter(logging.Filter): |
| 209 | ... def filter(self, record): |
| 210 | ... return record.levelno not in [SOCIABLE, TACITURN] |
| 211 | |
| 212 | >>> SHOULD1 = "This should only be seen at the '%s' logging level (or lower)" |
| 213 | |
| 214 | Configure the logger, and tell the logging system to associate names with our levels. |
| 215 | >>> logging.basicConfig(stream=sys.stdout) |
| 216 | >>> rootLogger = logging.getLogger("") |
| 217 | >>> rootLogger.setLevel(logging.DEBUG) |
| 218 | >>> for lvl in my_logging_levels.keys(): |
| 219 | ... logging.addLevelName(lvl, my_logging_levels[lvl]) |
| 220 | >>> log = logging.getLogger("") |
| 221 | >>> hdlr = log.handlers[0] |
| 222 | >>> from test_logging import message |
| 223 | |
| 224 | Set the logging level to each different value and call the utility |
| 225 | function to log events. In the output, you should see that each time |
| 226 | round the loop, the number of logging events which are actually output |
| 227 | decreases. |
| 228 | |
| 229 | >>> log.setLevel(1) |
| 230 | |
| 231 | >>> log.log(1, "This should only be seen at the '%s' logging level (or lower)", BORING) |
| 232 | BORING:root:This should only be seen at the '1' logging level (or lower) |
| 233 | |
| 234 | >>> log.log(2, "This should only be seen at the '%s' logging level (or lower)", CHATTERBOX) |
| 235 | CHATTERBOX:root:This should only be seen at the '2' logging level (or lower) |
| 236 | |
| 237 | >>> log.log(3, "This should only be seen at the '%s' logging level (or lower)", GARRULOUS) |
| 238 | GARRULOUS:root:This should only be seen at the '3' logging level (or lower) |
| 239 | |
| 240 | >>> log.log(4, "This should only be seen at the '%s' logging level (or lower)", TALKATIVE) |
| 241 | TALKATIVE:root:This should only be seen at the '4' logging level (or lower) |
| 242 | |
| 243 | >>> log.log(5, "This should only be seen at the '%s' logging level (or lower)", VERBOSE) |
| 244 | VERBOSE:root:This should only be seen at the '5' logging level (or lower) |
| 245 | |
| 246 | >>> log.log(6, "This should only be seen at the '%s' logging level (or lower)", SOCIABLE) |
| 247 | SOCIABLE:root:This should only be seen at the '6' logging level (or lower) |
| 248 | |
| 249 | >>> log.log(7, "This should only be seen at the '%s' logging level (or lower)", EFFUSIVE) |
| 250 | EFFUSIVE:root:This should only be seen at the '7' logging level (or lower) |
| 251 | |
| 252 | >>> log.log(8, "This should only be seen at the '%s' logging level (or lower)", TERSE) |
| 253 | TERSE:root:This should only be seen at the '8' logging level (or lower) |
| 254 | |
| 255 | >>> log.log(9, "This should only be seen at the '%s' logging level (or lower)", TACITURN) |
| 256 | TACITURN:root:This should only be seen at the '9' logging level (or lower) |
| 257 | |
| 258 | >>> log.log(10, "This should only be seen at the '%s' logging level (or lower)", SILENT) |
| 259 | SILENT:root:This should only be seen at the '10' logging level (or lower) |
| 260 | |
| 261 | >>> log.setLevel(0) |
| 262 | |
| 263 | >>> log.setLevel(2) |
| 264 | |
| 265 | >>> log.log(1, "This should only be seen at the '%s' logging level (or lower)", BORING) |
| 266 | |
| 267 | >>> log.log(2, "This should only be seen at the '%s' logging level (or lower)", CHATTERBOX) |
| 268 | CHATTERBOX:root:This should only be seen at the '2' logging level (or lower) |
| 269 | |
| 270 | >>> log.log(3, "This should only be seen at the '%s' logging level (or lower)", GARRULOUS) |
| 271 | GARRULOUS:root:This should only be seen at the '3' logging level (or lower) |
| 272 | |
| 273 | >>> log.log(4, "This should only be seen at the '%s' logging level (or lower)", TALKATIVE) |
| 274 | TALKATIVE:root:This should only be seen at the '4' logging level (or lower) |
| 275 | |
| 276 | >>> log.log(5, "This should only be seen at the '%s' logging level (or lower)", VERBOSE) |
| 277 | VERBOSE:root:This should only be seen at the '5' logging level (or lower) |
| 278 | |
| 279 | >>> log.log(6, "This should only be seen at the '%s' logging level (or lower)", SOCIABLE) |
| 280 | SOCIABLE:root:This should only be seen at the '6' logging level (or lower) |
| 281 | |
| 282 | >>> log.log(7, "This should only be seen at the '%s' logging level (or lower)", EFFUSIVE) |
| 283 | EFFUSIVE:root:This should only be seen at the '7' logging level (or lower) |
| 284 | |
| 285 | >>> log.log(8, "This should only be seen at the '%s' logging level (or lower)", TERSE) |
| 286 | TERSE:root:This should only be seen at the '8' logging level (or lower) |
| 287 | |
| 288 | >>> log.log(9, "This should only be seen at the '%s' logging level (or lower)", TACITURN) |
| 289 | TACITURN:root:This should only be seen at the '9' logging level (or lower) |
| 290 | |
| 291 | >>> log.log(10, "This should only be seen at the '%s' logging level (or lower)", SILENT) |
| 292 | SILENT:root:This should only be seen at the '10' logging level (or lower) |
| 293 | |
| 294 | >>> log.setLevel(3) |
| 295 | |
| 296 | >>> log.log(1, "This should only be seen at the '%s' logging level (or lower)", BORING) |
| 297 | |
| 298 | >>> log.log(2, "This should only be seen at the '%s' logging level (or lower)", CHATTERBOX) |
| 299 | |
| 300 | >>> log.log(3, "This should only be seen at the '%s' logging level (or lower)", GARRULOUS) |
| 301 | GARRULOUS:root:This should only be seen at the '3' logging level (or lower) |
| 302 | |
| 303 | >>> log.log(4, "This should only be seen at the '%s' logging level (or lower)", TALKATIVE) |
| 304 | TALKATIVE:root:This should only be seen at the '4' logging level (or lower) |
| 305 | |
| 306 | >>> log.log(5, "This should only be seen at the '%s' logging level (or lower)", VERBOSE) |
| 307 | VERBOSE:root:This should only be seen at the '5' logging level (or lower) |
| 308 | |
| 309 | >>> log.log(6, "This should only be seen at the '%s' logging level (or lower)", SOCIABLE) |
| 310 | SOCIABLE:root:This should only be seen at the '6' logging level (or lower) |
| 311 | |
| 312 | >>> log.log(7, "This should only be seen at the '%s' logging level (or lower)", EFFUSIVE) |
| 313 | EFFUSIVE:root:This should only be seen at the '7' logging level (or lower) |
| 314 | |
| 315 | >>> log.log(8, "This should only be seen at the '%s' logging level (or lower)", TERSE) |
| 316 | TERSE:root:This should only be seen at the '8' logging level (or lower) |
| 317 | |
| 318 | >>> log.log(9, "This should only be seen at the '%s' logging level (or lower)", TACITURN) |
| 319 | TACITURN:root:This should only be seen at the '9' logging level (or lower) |
| 320 | |
| 321 | >>> log.log(10, "This should only be seen at the '%s' logging level (or lower)", SILENT) |
| 322 | SILENT:root:This should only be seen at the '10' logging level (or lower) |
| 323 | |
| 324 | >>> log.setLevel(4) |
| 325 | |
| 326 | >>> log.log(1, "This should only be seen at the '%s' logging level (or lower)", BORING) |
| 327 | |
| 328 | >>> log.log(2, "This should only be seen at the '%s' logging level (or lower)", CHATTERBOX) |
| 329 | |
| 330 | >>> log.log(3, "This should only be seen at the '%s' logging level (or lower)", GARRULOUS) |
| 331 | |
| 332 | >>> log.log(4, "This should only be seen at the '%s' logging level (or lower)", TALKATIVE) |
| 333 | TALKATIVE:root:This should only be seen at the '4' logging level (or lower) |
| 334 | |
| 335 | >>> log.log(5, "This should only be seen at the '%s' logging level (or lower)", VERBOSE) |
| 336 | VERBOSE:root:This should only be seen at the '5' logging level (or lower) |
| 337 | |
| 338 | >>> log.log(6, "This should only be seen at the '%s' logging level (or lower)", SOCIABLE) |
| 339 | SOCIABLE:root:This should only be seen at the '6' logging level (or lower) |
| 340 | |
| 341 | >>> log.log(7, "This should only be seen at the '%s' logging level (or lower)", EFFUSIVE) |
| 342 | EFFUSIVE:root:This should only be seen at the '7' logging level (or lower) |
| 343 | |
| 344 | >>> log.log(8, "This should only be seen at the '%s' logging level (or lower)", TERSE) |
| 345 | TERSE:root:This should only be seen at the '8' logging level (or lower) |
| 346 | |
| 347 | >>> log.log(9, "This should only be seen at the '%s' logging level (or lower)", TACITURN) |
| 348 | TACITURN:root:This should only be seen at the '9' logging level (or lower) |
| 349 | |
| 350 | >>> log.log(10, "This should only be seen at the '%s' logging level (or lower)", SILENT) |
| 351 | SILENT:root:This should only be seen at the '10' logging level (or lower) |
| 352 | |
| 353 | >>> log.setLevel(5) |
| 354 | |
| 355 | >>> log.log(1, "This should only be seen at the '%s' logging level (or lower)", BORING) |
| 356 | |
| 357 | >>> log.log(2, "This should only be seen at the '%s' logging level (or lower)", CHATTERBOX) |
| 358 | |
| 359 | >>> log.log(3, "This should only be seen at the '%s' logging level (or lower)", GARRULOUS) |
| 360 | |
| 361 | >>> log.log(4, "This should only be seen at the '%s' logging level (or lower)", TALKATIVE) |
| 362 | |
| 363 | >>> log.log(5, "This should only be seen at the '%s' logging level (or lower)", VERBOSE) |
| 364 | VERBOSE:root:This should only be seen at the '5' logging level (or lower) |
| 365 | |
| 366 | >>> log.log(6, "This should only be seen at the '%s' logging level (or lower)", SOCIABLE) |
| 367 | SOCIABLE:root:This should only be seen at the '6' logging level (or lower) |
| 368 | |
| 369 | >>> log.log(7, "This should only be seen at the '%s' logging level (or lower)", EFFUSIVE) |
| 370 | EFFUSIVE:root:This should only be seen at the '7' logging level (or lower) |
| 371 | |
| 372 | >>> log.log(8, "This should only be seen at the '%s' logging level (or lower)", TERSE) |
| 373 | TERSE:root:This should only be seen at the '8' logging level (or lower) |
| 374 | |
| 375 | >>> log.log(9, "This should only be seen at the '%s' logging level (or lower)", TACITURN) |
| 376 | TACITURN:root:This should only be seen at the '9' logging level (or lower) |
| 377 | |
| 378 | >>> log.log(10, "This should only be seen at the '%s' logging level (or lower)", SILENT) |
| 379 | SILENT:root:This should only be seen at the '10' logging level (or lower) |
| 380 | |
| 381 | |
| 382 | >>> log.setLevel(6) |
| 383 | |
| 384 | >>> log.log(1, "This should only be seen at the '%s' logging level (or lower)", BORING) |
| 385 | |
| 386 | >>> log.log(2, "This should only be seen at the '%s' logging level (or lower)", CHATTERBOX) |
| 387 | |
| 388 | >>> log.log(3, "This should only be seen at the '%s' logging level (or lower)", GARRULOUS) |
| 389 | |
| 390 | >>> log.log(4, "This should only be seen at the '%s' logging level (or lower)", TALKATIVE) |
| 391 | |
| 392 | >>> log.log(5, "This should only be seen at the '%s' logging level (or lower)", VERBOSE) |
| 393 | |
| 394 | >>> log.log(6, "This should only be seen at the '%s' logging level (or lower)", SOCIABLE) |
| 395 | SOCIABLE:root:This should only be seen at the '6' logging level (or lower) |
| 396 | |
| 397 | >>> log.log(7, "This should only be seen at the '%s' logging level (or lower)", EFFUSIVE) |
| 398 | EFFUSIVE:root:This should only be seen at the '7' logging level (or lower) |
| 399 | |
| 400 | >>> log.log(8, "This should only be seen at the '%s' logging level (or lower)", TERSE) |
| 401 | TERSE:root:This should only be seen at the '8' logging level (or lower) |
| 402 | |
| 403 | >>> log.log(9, "This should only be seen at the '%s' logging level (or lower)", TACITURN) |
| 404 | TACITURN:root:This should only be seen at the '9' logging level (or lower) |
| 405 | |
| 406 | >>> log.log(10, "This should only be seen at the '%s' logging level (or lower)", SILENT) |
| 407 | SILENT:root:This should only be seen at the '10' logging level (or lower) |
| 408 | |
| 409 | >>> log.setLevel(7) |
| 410 | |
| 411 | >>> log.log(1, "This should only be seen at the '%s' logging level (or lower)", BORING) |
| 412 | |
| 413 | >>> log.log(2, "This should only be seen at the '%s' logging level (or lower)", CHATTERBOX) |
| 414 | |
| 415 | >>> log.log(3, "This should only be seen at the '%s' logging level (or lower)", GARRULOUS) |
| 416 | |
| 417 | >>> log.log(4, "This should only be seen at the '%s' logging level (or lower)", TALKATIVE) |
| 418 | |
| 419 | >>> log.log(5, "This should only be seen at the '%s' logging level (or lower)", VERBOSE) |
| 420 | |
| 421 | >>> log.log(6, "This should only be seen at the '%s' logging level (or lower)", SOCIABLE) |
| 422 | |
| 423 | >>> log.log(7, "This should only be seen at the '%s' logging level (or lower)", EFFUSIVE) |
| 424 | EFFUSIVE:root:This should only be seen at the '7' logging level (or lower) |
| 425 | |
| 426 | >>> log.log(8, "This should only be seen at the '%s' logging level (or lower)", TERSE) |
| 427 | TERSE:root:This should only be seen at the '8' logging level (or lower) |
| 428 | |
| 429 | >>> log.log(9, "This should only be seen at the '%s' logging level (or lower)", TACITURN) |
| 430 | TACITURN:root:This should only be seen at the '9' logging level (or lower) |
| 431 | |
| 432 | >>> log.log(10, "This should only be seen at the '%s' logging level (or lower)", SILENT) |
| 433 | SILENT:root:This should only be seen at the '10' logging level (or lower) |
| 434 | |
| 435 | >>> log.setLevel(8) |
| 436 | |
| 437 | >>> log.log(1, "This should only be seen at the '%s' logging level (or lower)", BORING) |
| 438 | |
| 439 | >>> log.log(2, "This should only be seen at the '%s' logging level (or lower)", CHATTERBOX) |
| 440 | |
| 441 | >>> log.log(3, "This should only be seen at the '%s' logging level (or lower)", GARRULOUS) |
| 442 | |
| 443 | >>> log.log(4, "This should only be seen at the '%s' logging level (or lower)", TALKATIVE) |
| 444 | |
| 445 | >>> log.log(5, "This should only be seen at the '%s' logging level (or lower)", VERBOSE) |
| 446 | |
| 447 | >>> log.log(6, "This should only be seen at the '%s' logging level (or lower)", SOCIABLE) |
| 448 | |
| 449 | >>> log.log(7, "This should only be seen at the '%s' logging level (or lower)", EFFUSIVE) |
| 450 | |
| 451 | >>> log.log(8, "This should only be seen at the '%s' logging level (or lower)", TERSE) |
| 452 | TERSE:root:This should only be seen at the '8' logging level (or lower) |
| 453 | |
| 454 | >>> log.log(9, "This should only be seen at the '%s' logging level (or lower)", TACITURN) |
| 455 | TACITURN:root:This should only be seen at the '9' logging level (or lower) |
| 456 | |
| 457 | >>> log.log(10, "This should only be seen at the '%s' logging level (or lower)", SILENT) |
| 458 | SILENT:root:This should only be seen at the '10' logging level (or lower) |
| 459 | |
| 460 | >>> log.setLevel(0) |
| 461 | |
| 462 | >>> log.setLevel(9) |
| 463 | |
| 464 | >>> log.log(1, "This should only be seen at the '%s' logging level (or lower)", BORING) |
| 465 | |
| 466 | >>> log.log(2, "This should only be seen at the '%s' logging level (or lower)", CHATTERBOX) |
| 467 | |
| 468 | >>> log.log(3, "This should only be seen at the '%s' logging level (or lower)", GARRULOUS) |
| 469 | |
| 470 | >>> log.log(4, "This should only be seen at the '%s' logging level (or lower)", TALKATIVE) |
| 471 | |
| 472 | >>> log.log(5, "This should only be seen at the '%s' logging level (or lower)", VERBOSE) |
| 473 | |
| 474 | >>> log.log(6, "This should only be seen at the '%s' logging level (or lower)", SOCIABLE) |
| 475 | |
| 476 | >>> log.log(7, "This should only be seen at the '%s' logging level (or lower)", EFFUSIVE) |
| 477 | |
| 478 | >>> log.log(8, "This should only be seen at the '%s' logging level (or lower)", TERSE) |
| 479 | |
| 480 | >>> log.log(9, "This should only be seen at the '%s' logging level (or lower)", TACITURN) |
| 481 | TACITURN:root:This should only be seen at the '9' logging level (or lower) |
| 482 | |
| 483 | >>> log.log(10, "This should only be seen at the '%s' logging level (or lower)", SILENT) |
| 484 | SILENT:root:This should only be seen at the '10' logging level (or lower) |
| 485 | |
| 486 | >>> log.setLevel(0) |
| 487 | |
| 488 | >>> log.setLevel(10) |
| 489 | |
| 490 | >>> log.log(1, "This should only be seen at the '%s' logging level (or lower)", BORING) |
| 491 | |
| 492 | >>> log.log(2, "This should only be seen at the '%s' logging level (or lower)", CHATTERBOX) |
| 493 | |
| 494 | >>> log.log(3, "This should only be seen at the '%s' logging level (or lower)", GARRULOUS) |
| 495 | |
| 496 | >>> log.log(4, "This should only be seen at the '%s' logging level (or lower)", TALKATIVE) |
| 497 | |
| 498 | >>> log.log(5, "This should only be seen at the '%s' logging level (or lower)", VERBOSE) |
| 499 | |
| 500 | >>> log.log(6, "This should only be seen at the '%s' logging level (or lower)", SOCIABLE) |
| 501 | |
| 502 | >>> log.log(7, "This should only be seen at the '%s' logging level (or lower)", EFFUSIVE) |
| 503 | |
| 504 | >>> log.log(8, "This should only be seen at the '%s' logging level (or lower)", TERSE) |
| 505 | |
| 506 | >>> log.log(9, "This should only be seen at the '%s' logging level (or lower)", TACITURN) |
| 507 | |
| 508 | >>> log.log(10, "This should only be seen at the '%s' logging level (or lower)", SILENT) |
| 509 | SILENT:root:This should only be seen at the '10' logging level (or lower) |
| 510 | |
| 511 | >>> hdlr.setLevel(SOCIABLE) |
| 512 | |
| 513 | >>> log.setLevel(1) |
| 514 | |
| 515 | >>> log.log(1, "This should only be seen at the '%s' logging level (or lower)", BORING) |
| 516 | |
| 517 | >>> log.log(2, "This should only be seen at the '%s' logging level (or lower)", CHATTERBOX) |
| 518 | |
| 519 | >>> log.log(3, "This should only be seen at the '%s' logging level (or lower)", GARRULOUS) |
| 520 | |
| 521 | >>> log.log(4, "This should only be seen at the '%s' logging level (or lower)", TALKATIVE) |
| 522 | |
| 523 | >>> log.log(5, "This should only be seen at the '%s' logging level (or lower)", VERBOSE) |
| 524 | |
| 525 | >>> log.log(6, "This should only be seen at the '%s' logging level (or lower)", SOCIABLE) |
| 526 | SOCIABLE:root:This should only be seen at the '6' logging level (or lower) |
| 527 | |
| 528 | >>> log.log(7, "This should only be seen at the '%s' logging level (or lower)", EFFUSIVE) |
| 529 | EFFUSIVE:root:This should only be seen at the '7' logging level (or lower) |
| 530 | |
| 531 | >>> log.log(8, "This should only be seen at the '%s' logging level (or lower)", TERSE) |
| 532 | TERSE:root:This should only be seen at the '8' logging level (or lower) |
| 533 | |
| 534 | >>> log.log(9, "This should only be seen at the '%s' logging level (or lower)", TACITURN) |
| 535 | TACITURN:root:This should only be seen at the '9' logging level (or lower) |
| 536 | |
| 537 | >>> log.log(10, "This should only be seen at the '%s' logging level (or lower)", SILENT) |
| 538 | SILENT:root:This should only be seen at the '10' logging level (or lower) |
| 539 | |
| 540 | >>> log.setLevel(2) |
| 541 | |
| 542 | >>> log.log(1, "This should only be seen at the '%s' logging level (or lower)", BORING) |
| 543 | |
| 544 | >>> log.log(2, "This should only be seen at the '%s' logging level (or lower)", CHATTERBOX) |
| 545 | |
| 546 | >>> log.log(3, "This should only be seen at the '%s' logging level (or lower)", GARRULOUS) |
| 547 | |
| 548 | >>> log.log(4, "This should only be seen at the '%s' logging level (or lower)", TALKATIVE) |
| 549 | |
| 550 | >>> log.log(5, "This should only be seen at the '%s' logging level (or lower)", VERBOSE) |
| 551 | |
| 552 | >>> log.log(6, "This should only be seen at the '%s' logging level (or lower)", SOCIABLE) |
| 553 | SOCIABLE:root:This should only be seen at the '6' logging level (or lower) |
| 554 | |
| 555 | >>> log.log(7, "This should only be seen at the '%s' logging level (or lower)", EFFUSIVE) |
| 556 | EFFUSIVE:root:This should only be seen at the '7' logging level (or lower) |
| 557 | |
| 558 | >>> log.log(8, "This should only be seen at the '%s' logging level (or lower)", TERSE) |
| 559 | TERSE:root:This should only be seen at the '8' logging level (or lower) |
| 560 | |
| 561 | >>> log.log(9, "This should only be seen at the '%s' logging level (or lower)", TACITURN) |
| 562 | TACITURN:root:This should only be seen at the '9' logging level (or lower) |
| 563 | |
| 564 | >>> log.log(10, "This should only be seen at the '%s' logging level (or lower)", SILENT) |
| 565 | SILENT:root:This should only be seen at the '10' logging level (or lower) |
| 566 | |
| 567 | >>> log.setLevel(3) |
| 568 | |
| 569 | >>> log.log(1, "This should only be seen at the '%s' logging level (or lower)", BORING) |
| 570 | |
| 571 | >>> log.log(2, "This should only be seen at the '%s' logging level (or lower)", CHATTERBOX) |
| 572 | |
| 573 | >>> log.log(3, "This should only be seen at the '%s' logging level (or lower)", GARRULOUS) |
| 574 | |
| 575 | >>> log.log(4, "This should only be seen at the '%s' logging level (or lower)", TALKATIVE) |
| 576 | |
| 577 | >>> log.log(5, "This should only be seen at the '%s' logging level (or lower)", VERBOSE) |
| 578 | |
| 579 | >>> log.log(6, "This should only be seen at the '%s' logging level (or lower)", SOCIABLE) |
| 580 | SOCIABLE:root:This should only be seen at the '6' logging level (or lower) |
| 581 | |
| 582 | >>> log.log(7, "This should only be seen at the '%s' logging level (or lower)", EFFUSIVE) |
| 583 | EFFUSIVE:root:This should only be seen at the '7' logging level (or lower) |
| 584 | |
| 585 | >>> log.log(8, "This should only be seen at the '%s' logging level (or lower)", TERSE) |
| 586 | TERSE:root:This should only be seen at the '8' logging level (or lower) |
| 587 | |
| 588 | >>> log.log(9, "This should only be seen at the '%s' logging level (or lower)", TACITURN) |
| 589 | TACITURN:root:This should only be seen at the '9' logging level (or lower) |
| 590 | |
| 591 | >>> log.log(10, "This should only be seen at the '%s' logging level (or lower)", SILENT) |
| 592 | SILENT:root:This should only be seen at the '10' logging level (or lower) |
| 593 | |
| 594 | >>> log.setLevel(0) |
| 595 | |
| 596 | >>> log.setLevel(4) |
| 597 | |
| 598 | >>> log.log(1, "This should only be seen at the '%s' logging level (or lower)", BORING) |
| 599 | |
| 600 | >>> log.log(2, "This should only be seen at the '%s' logging level (or lower)", CHATTERBOX) |
| 601 | |
| 602 | >>> log.log(3, "This should only be seen at the '%s' logging level (or lower)", GARRULOUS) |
| 603 | |
| 604 | >>> log.log(4, "This should only be seen at the '%s' logging level (or lower)", TALKATIVE) |
| 605 | |
| 606 | >>> log.log(5, "This should only be seen at the '%s' logging level (or lower)", VERBOSE) |
| 607 | |
| 608 | >>> log.log(6, "This should only be seen at the '%s' logging level (or lower)", SOCIABLE) |
| 609 | SOCIABLE:root:This should only be seen at the '6' logging level (or lower) |
| 610 | |
| 611 | >>> log.log(7, "This should only be seen at the '%s' logging level (or lower)", EFFUSIVE) |
| 612 | EFFUSIVE:root:This should only be seen at the '7' logging level (or lower) |
| 613 | |
| 614 | >>> log.log(8, "This should only be seen at the '%s' logging level (or lower)", TERSE) |
| 615 | TERSE:root:This should only be seen at the '8' logging level (or lower) |
| 616 | |
| 617 | >>> log.log(9, "This should only be seen at the '%s' logging level (or lower)", TACITURN) |
| 618 | TACITURN:root:This should only be seen at the '9' logging level (or lower) |
| 619 | |
| 620 | >>> log.log(10, "This should only be seen at the '%s' logging level (or lower)", SILENT) |
| 621 | SILENT:root:This should only be seen at the '10' logging level (or lower) |
| 622 | |
| 623 | >>> log.setLevel(0) |
| 624 | |
| 625 | >>> log.setLevel(5) |
| 626 | |
| 627 | >>> log.log(1, "This should only be seen at the '%s' logging level (or lower)", BORING) |
| 628 | |
| 629 | >>> log.log(2, "This should only be seen at the '%s' logging level (or lower)", CHATTERBOX) |
| 630 | |
| 631 | >>> log.log(3, "This should only be seen at the '%s' logging level (or lower)", GARRULOUS) |
| 632 | |
| 633 | >>> log.log(4, "This should only be seen at the '%s' logging level (or lower)", TALKATIVE) |
| 634 | |
| 635 | >>> log.log(5, "This should only be seen at the '%s' logging level (or lower)", VERBOSE) |
| 636 | |
| 637 | >>> log.log(6, "This should only be seen at the '%s' logging level (or lower)", SOCIABLE) |
| 638 | SOCIABLE:root:This should only be seen at the '6' logging level (or lower) |
| 639 | |
| 640 | >>> log.log(7, "This should only be seen at the '%s' logging level (or lower)", EFFUSIVE) |
| 641 | EFFUSIVE:root:This should only be seen at the '7' logging level (or lower) |
| 642 | |
| 643 | >>> log.log(8, "This should only be seen at the '%s' logging level (or lower)", TERSE) |
| 644 | TERSE:root:This should only be seen at the '8' logging level (or lower) |
| 645 | |
| 646 | >>> log.log(9, "This should only be seen at the '%s' logging level (or lower)", TACITURN) |
| 647 | TACITURN:root:This should only be seen at the '9' logging level (or lower) |
| 648 | |
| 649 | >>> log.log(10, "This should only be seen at the '%s' logging level (or lower)", SILENT) |
| 650 | SILENT:root:This should only be seen at the '10' logging level (or lower) |
| 651 | |
| 652 | >>> log.setLevel(0) |
| 653 | |
| 654 | >>> log.setLevel(6) |
| 655 | |
| 656 | >>> log.log(1, "This should only be seen at the '%s' logging level (or lower)", BORING) |
| 657 | |
| 658 | >>> log.log(2, "This should only be seen at the '%s' logging level (or lower)", CHATTERBOX) |
| 659 | |
| 660 | >>> log.log(3, "This should only be seen at the '%s' logging level (or lower)", GARRULOUS) |
| 661 | |
| 662 | >>> log.log(4, "This should only be seen at the '%s' logging level (or lower)", TALKATIVE) |
| 663 | |
| 664 | >>> log.log(5, "This should only be seen at the '%s' logging level (or lower)", VERBOSE) |
| 665 | |
| 666 | >>> log.log(6, "This should only be seen at the '%s' logging level (or lower)", SOCIABLE) |
| 667 | SOCIABLE:root:This should only be seen at the '6' logging level (or lower) |
| 668 | |
| 669 | >>> log.log(7, "This should only be seen at the '%s' logging level (or lower)", EFFUSIVE) |
| 670 | EFFUSIVE:root:This should only be seen at the '7' logging level (or lower) |
| 671 | |
| 672 | >>> log.log(8, "This should only be seen at the '%s' logging level (or lower)", TERSE) |
| 673 | TERSE:root:This should only be seen at the '8' logging level (or lower) |
| 674 | |
| 675 | >>> log.log(9, "This should only be seen at the '%s' logging level (or lower)", TACITURN) |
| 676 | TACITURN:root:This should only be seen at the '9' logging level (or lower) |
| 677 | |
| 678 | >>> log.log(10, "This should only be seen at the '%s' logging level (or lower)", SILENT) |
| 679 | SILENT:root:This should only be seen at the '10' logging level (or lower) |
| 680 | |
| 681 | >>> log.setLevel(0) |
| 682 | |
| 683 | >>> log.setLevel(7) |
| 684 | |
| 685 | >>> log.log(1, "This should only be seen at the '%s' logging level (or lower)", BORING) |
| 686 | |
| 687 | >>> log.log(2, "This should only be seen at the '%s' logging level (or lower)", CHATTERBOX) |
| 688 | |
| 689 | >>> log.log(3, "This should only be seen at the '%s' logging level (or lower)", GARRULOUS) |
| 690 | |
| 691 | >>> log.log(4, "This should only be seen at the '%s' logging level (or lower)", TALKATIVE) |
| 692 | |
| 693 | >>> log.log(5, "This should only be seen at the '%s' logging level (or lower)", VERBOSE) |
| 694 | |
| 695 | >>> log.log(6, "This should only be seen at the '%s' logging level (or lower)", SOCIABLE) |
| 696 | |
| 697 | >>> log.log(7, "This should only be seen at the '%s' logging level (or lower)", EFFUSIVE) |
| 698 | EFFUSIVE:root:This should only be seen at the '7' logging level (or lower) |
| 699 | |
| 700 | >>> log.log(8, "This should only be seen at the '%s' logging level (or lower)", TERSE) |
| 701 | TERSE:root:This should only be seen at the '8' logging level (or lower) |
| 702 | |
| 703 | >>> log.log(9, "This should only be seen at the '%s' logging level (or lower)", TACITURN) |
| 704 | TACITURN:root:This should only be seen at the '9' logging level (or lower) |
| 705 | |
| 706 | >>> log.log(10, "This should only be seen at the '%s' logging level (or lower)", SILENT) |
| 707 | SILENT:root:This should only be seen at the '10' logging level (or lower) |
| 708 | |
| 709 | >>> log.setLevel(0) |
| 710 | |
| 711 | >>> log.setLevel(8) |
| 712 | |
| 713 | >>> log.log(1, "This should only be seen at the '%s' logging level (or lower)", BORING) |
| 714 | |
| 715 | >>> log.log(2, "This should only be seen at the '%s' logging level (or lower)", CHATTERBOX) |
| 716 | |
| 717 | >>> log.log(3, "This should only be seen at the '%s' logging level (or lower)", GARRULOUS) |
| 718 | |
| 719 | >>> log.log(4, "This should only be seen at the '%s' logging level (or lower)", TALKATIVE) |
| 720 | |
| 721 | >>> log.log(5, "This should only be seen at the '%s' logging level (or lower)", VERBOSE) |
| 722 | |
| 723 | >>> log.log(6, "This should only be seen at the '%s' logging level (or lower)", SOCIABLE) |
| 724 | |
| 725 | >>> log.log(7, "This should only be seen at the '%s' logging level (or lower)", EFFUSIVE) |
| 726 | |
| 727 | >>> log.log(8, "This should only be seen at the '%s' logging level (or lower)", TERSE) |
| 728 | TERSE:root:This should only be seen at the '8' logging level (or lower) |
| 729 | |
| 730 | >>> log.log(9, "This should only be seen at the '%s' logging level (or lower)", TACITURN) |
| 731 | TACITURN:root:This should only be seen at the '9' logging level (or lower) |
| 732 | |
| 733 | >>> log.log(10, "This should only be seen at the '%s' logging level (or lower)", SILENT) |
| 734 | SILENT:root:This should only be seen at the '10' logging level (or lower) |
| 735 | |
| 736 | >>> log.setLevel(0) |
| 737 | |
| 738 | >>> log.setLevel(9) |
| 739 | |
| 740 | >>> log.log(1, "This should only be seen at the '%s' logging level (or lower)", BORING) |
| 741 | |
| 742 | >>> log.log(2, "This should only be seen at the '%s' logging level (or lower)", CHATTERBOX) |
| 743 | |
| 744 | >>> log.log(3, "This should only be seen at the '%s' logging level (or lower)", GARRULOUS) |
| 745 | |
| 746 | >>> log.log(4, "This should only be seen at the '%s' logging level (or lower)", TALKATIVE) |
| 747 | |
| 748 | >>> log.log(5, "This should only be seen at the '%s' logging level (or lower)", VERBOSE) |
| 749 | |
| 750 | >>> log.log(6, "This should only be seen at the '%s' logging level (or lower)", SOCIABLE) |
| 751 | |
| 752 | >>> log.log(7, "This should only be seen at the '%s' logging level (or lower)", EFFUSIVE) |
| 753 | |
| 754 | >>> log.log(8, "This should only be seen at the '%s' logging level (or lower)", TERSE) |
| 755 | |
| 756 | >>> log.log(9, "This should only be seen at the '%s' logging level (or lower)", TACITURN) |
| 757 | TACITURN:root:This should only be seen at the '9' logging level (or lower) |
| 758 | |
| 759 | >>> log.log(10, "This should only be seen at the '%s' logging level (or lower)", SILENT) |
| 760 | SILENT:root:This should only be seen at the '10' logging level (or lower) |
| 761 | |
| 762 | >>> log.setLevel(0) |
| 763 | |
| 764 | >>> log.setLevel(10) |
| 765 | |
| 766 | >>> log.log(1, "This should only be seen at the '%s' logging level (or lower)", BORING) |
| 767 | |
| 768 | >>> log.log(2, "This should only be seen at the '%s' logging level (or lower)", CHATTERBOX) |
| 769 | |
| 770 | >>> log.log(3, "This should only be seen at the '%s' logging level (or lower)", GARRULOUS) |
| 771 | |
| 772 | >>> log.log(4, "This should only be seen at the '%s' logging level (or lower)", TALKATIVE) |
| 773 | |
| 774 | >>> log.log(5, "This should only be seen at the '%s' logging level (or lower)", VERBOSE) |
| 775 | |
| 776 | >>> log.log(6, "This should only be seen at the '%s' logging level (or lower)", SOCIABLE) |
| 777 | |
| 778 | >>> log.log(7, "This should only be seen at the '%s' logging level (or lower)", EFFUSIVE) |
| 779 | |
| 780 | >>> log.log(8, "This should only be seen at the '%s' logging level (or lower)", TERSE) |
| 781 | |
| 782 | >>> log.log(9, "This should only be seen at the '%s' logging level (or lower)", TACITURN) |
| 783 | |
| 784 | >>> log.log(10, "This should only be seen at the '%s' logging level (or lower)", SILENT) |
| 785 | SILENT:root:This should only be seen at the '10' logging level (or lower) |
| 786 | |
| 787 | >>> log.setLevel(0) |
| 788 | |
| 789 | >>> |
| 790 | |
| 791 | >>> hdlr.setLevel(0) |
| 792 | |
| 793 | >>> garr = GarrulousFilter() |
| 794 | |
| 795 | >>> hdlr.addFilter(garr) |
| 796 | |
| 797 | >>> log.setLevel(1) |
| 798 | |
| 799 | >>> log.log(1, "This should only be seen at the '%s' logging level (or lower)", BORING) |
| 800 | BORING:root:This should only be seen at the '1' logging level (or lower) |
| 801 | |
| 802 | >>> log.log(2, "This should only be seen at the '%s' logging level (or lower)", CHATTERBOX) |
| 803 | CHATTERBOX:root:This should only be seen at the '2' logging level (or lower) |
| 804 | |
| 805 | >>> log.log(3, "This should only be seen at the '%s' logging level (or lower)", GARRULOUS) |
| 806 | |
| 807 | >>> log.log(4, "This should only be seen at the '%s' logging level (or lower)", TALKATIVE) |
| 808 | TALKATIVE:root:This should only be seen at the '4' logging level (or lower) |
| 809 | |
| 810 | >>> log.log(5, "This should only be seen at the '%s' logging level (or lower)", VERBOSE) |
| 811 | VERBOSE:root:This should only be seen at the '5' logging level (or lower) |
| 812 | |
| 813 | >>> log.log(6, "This should only be seen at the '%s' logging level (or lower)", SOCIABLE) |
| 814 | SOCIABLE:root:This should only be seen at the '6' logging level (or lower) |
| 815 | |
| 816 | >>> log.log(7, "This should only be seen at the '%s' logging level (or lower)", EFFUSIVE) |
| 817 | EFFUSIVE:root:This should only be seen at the '7' logging level (or lower) |
| 818 | |
| 819 | >>> log.log(8, "This should only be seen at the '%s' logging level (or lower)", TERSE) |
| 820 | TERSE:root:This should only be seen at the '8' logging level (or lower) |
| 821 | |
| 822 | >>> log.log(9, "This should only be seen at the '%s' logging level (or lower)", TACITURN) |
| 823 | TACITURN:root:This should only be seen at the '9' logging level (or lower) |
| 824 | |
| 825 | >>> log.log(10, "This should only be seen at the '%s' logging level (or lower)", SILENT) |
| 826 | SILENT:root:This should only be seen at the '10' logging level (or lower) |
| 827 | |
| 828 | >>> log.setLevel(2) |
| 829 | |
| 830 | >>> log.log(1, "This should only be seen at the '%s' logging level (or lower)", BORING) |
| 831 | |
| 832 | >>> log.log(2, "This should only be seen at the '%s' logging level (or lower)", CHATTERBOX) |
| 833 | CHATTERBOX:root:This should only be seen at the '2' logging level (or lower) |
| 834 | |
| 835 | >>> log.log(3, "This should only be seen at the '%s' logging level (or lower)", GARRULOUS) |
| 836 | |
| 837 | >>> log.log(4, "This should only be seen at the '%s' logging level (or lower)", TALKATIVE) |
| 838 | TALKATIVE:root:This should only be seen at the '4' logging level (or lower) |
| 839 | |
| 840 | >>> log.log(5, "This should only be seen at the '%s' logging level (or lower)", VERBOSE) |
| 841 | VERBOSE:root:This should only be seen at the '5' logging level (or lower) |
| 842 | |
| 843 | >>> log.log(6, "This should only be seen at the '%s' logging level (or lower)", SOCIABLE) |
| 844 | SOCIABLE:root:This should only be seen at the '6' logging level (or lower) |
| 845 | |
| 846 | >>> log.log(7, "This should only be seen at the '%s' logging level (or lower)", EFFUSIVE) |
| 847 | EFFUSIVE:root:This should only be seen at the '7' logging level (or lower) |
| 848 | |
| 849 | >>> log.log(8, "This should only be seen at the '%s' logging level (or lower)", TERSE) |
| 850 | TERSE:root:This should only be seen at the '8' logging level (or lower) |
| 851 | |
| 852 | >>> log.log(9, "This should only be seen at the '%s' logging level (or lower)", TACITURN) |
| 853 | TACITURN:root:This should only be seen at the '9' logging level (or lower) |
| 854 | |
| 855 | >>> log.log(10, "This should only be seen at the '%s' logging level (or lower)", SILENT) |
| 856 | SILENT:root:This should only be seen at the '10' logging level (or lower) |
| 857 | |
| 858 | >>> log.setLevel(3) |
| 859 | |
| 860 | >>> log.log(1, "This should only be seen at the '%s' logging level (or lower)", BORING) |
| 861 | |
| 862 | >>> log.log(2, "This should only be seen at the '%s' logging level (or lower)", CHATTERBOX) |
| 863 | |
| 864 | >>> log.log(3, "This should only be seen at the '%s' logging level (or lower)", GARRULOUS) |
| 865 | |
| 866 | >>> log.log(4, "This should only be seen at the '%s' logging level (or lower)", TALKATIVE) |
| 867 | TALKATIVE:root:This should only be seen at the '4' logging level (or lower) |
| 868 | |
| 869 | >>> log.log(5, "This should only be seen at the '%s' logging level (or lower)", VERBOSE) |
| 870 | VERBOSE:root:This should only be seen at the '5' logging level (or lower) |
| 871 | |
| 872 | >>> log.log(6, "This should only be seen at the '%s' logging level (or lower)", SOCIABLE) |
| 873 | SOCIABLE:root:This should only be seen at the '6' logging level (or lower) |
| 874 | |
| 875 | >>> log.log(7, "This should only be seen at the '%s' logging level (or lower)", EFFUSIVE) |
| 876 | EFFUSIVE:root:This should only be seen at the '7' logging level (or lower) |
| 877 | |
| 878 | >>> log.log(8, "This should only be seen at the '%s' logging level (or lower)", TERSE) |
| 879 | TERSE:root:This should only be seen at the '8' logging level (or lower) |
| 880 | |
| 881 | >>> log.log(9, "This should only be seen at the '%s' logging level (or lower)", TACITURN) |
| 882 | TACITURN:root:This should only be seen at the '9' logging level (or lower) |
| 883 | |
| 884 | >>> log.log(10, "This should only be seen at the '%s' logging level (or lower)", SILENT) |
| 885 | SILENT:root:This should only be seen at the '10' logging level (or lower) |
| 886 | |
| 887 | >>> log.setLevel(4) |
| 888 | |
| 889 | >>> log.log(1, "This should only be seen at the '%s' logging level (or lower)", BORING) |
| 890 | |
| 891 | >>> log.log(2, "This should only be seen at the '%s' logging level (or lower)", CHATTERBOX) |
| 892 | |
| 893 | >>> log.log(3, "This should only be seen at the '%s' logging level (or lower)", GARRULOUS) |
| 894 | |
| 895 | >>> log.log(4, "This should only be seen at the '%s' logging level (or lower)", TALKATIVE) |
| 896 | TALKATIVE:root:This should only be seen at the '4' logging level (or lower) |
| 897 | |
| 898 | >>> log.log(5, "This should only be seen at the '%s' logging level (or lower)", VERBOSE) |
| 899 | VERBOSE:root:This should only be seen at the '5' logging level (or lower) |
| 900 | |
| 901 | >>> log.log(6, "This should only be seen at the '%s' logging level (or lower)", SOCIABLE) |
| 902 | SOCIABLE:root:This should only be seen at the '6' logging level (or lower) |
| 903 | |
| 904 | >>> log.log(7, "This should only be seen at the '%s' logging level (or lower)", EFFUSIVE) |
| 905 | EFFUSIVE:root:This should only be seen at the '7' logging level (or lower) |
| 906 | |
| 907 | >>> log.log(8, "This should only be seen at the '%s' logging level (or lower)", TERSE) |
| 908 | TERSE:root:This should only be seen at the '8' logging level (or lower) |
| 909 | |
| 910 | >>> log.log(9, "This should only be seen at the '%s' logging level (or lower)", TACITURN) |
| 911 | TACITURN:root:This should only be seen at the '9' logging level (or lower) |
| 912 | |
| 913 | >>> log.log(10, "This should only be seen at the '%s' logging level (or lower)", SILENT) |
| 914 | SILENT:root:This should only be seen at the '10' logging level (or lower) |
| 915 | |
| 916 | >>> log.setLevel(5) |
| 917 | |
| 918 | >>> log.log(1, "This should only be seen at the '%s' logging level (or lower)", BORING) |
| 919 | |
| 920 | >>> log.log(2, "This should only be seen at the '%s' logging level (or lower)", CHATTERBOX) |
| 921 | |
| 922 | >>> log.log(3, "This should only be seen at the '%s' logging level (or lower)", GARRULOUS) |
| 923 | |
| 924 | >>> log.log(4, "This should only be seen at the '%s' logging level (or lower)", TALKATIVE) |
| 925 | |
| 926 | >>> log.log(5, "This should only be seen at the '%s' logging level (or lower)", VERBOSE) |
| 927 | VERBOSE:root:This should only be seen at the '5' logging level (or lower) |
| 928 | |
| 929 | >>> log.log(6, "This should only be seen at the '%s' logging level (or lower)", SOCIABLE) |
| 930 | SOCIABLE:root:This should only be seen at the '6' logging level (or lower) |
| 931 | |
| 932 | >>> log.log(7, "This should only be seen at the '%s' logging level (or lower)", EFFUSIVE) |
| 933 | EFFUSIVE:root:This should only be seen at the '7' logging level (or lower) |
| 934 | |
| 935 | >>> log.log(8, "This should only be seen at the '%s' logging level (or lower)", TERSE) |
| 936 | TERSE:root:This should only be seen at the '8' logging level (or lower) |
| 937 | |
| 938 | >>> log.log(9, "This should only be seen at the '%s' logging level (or lower)", TACITURN) |
| 939 | TACITURN:root:This should only be seen at the '9' logging level (or lower) |
| 940 | |
| 941 | >>> log.log(10, "This should only be seen at the '%s' logging level (or lower)", SILENT) |
| 942 | SILENT:root:This should only be seen at the '10' logging level (or lower) |
| 943 | |
| 944 | >>> log.setLevel(0) |
| 945 | |
| 946 | >>> log.setLevel(6) |
| 947 | |
| 948 | >>> log.log(1, "This should only be seen at the '%s' logging level (or lower)", BORING) |
| 949 | |
| 950 | >>> log.log(2, "This should only be seen at the '%s' logging level (or lower)", CHATTERBOX) |
| 951 | |
| 952 | >>> log.log(3, "This should only be seen at the '%s' logging level (or lower)", GARRULOUS) |
| 953 | |
| 954 | >>> log.log(4, "This should only be seen at the '%s' logging level (or lower)", TALKATIVE) |
| 955 | |
| 956 | >>> log.log(5, "This should only be seen at the '%s' logging level (or lower)", VERBOSE) |
| 957 | |
| 958 | >>> log.log(6, "This should only be seen at the '%s' logging level (or lower)", SOCIABLE) |
| 959 | SOCIABLE:root:This should only be seen at the '6' logging level (or lower) |
| 960 | |
| 961 | >>> log.log(7, "This should only be seen at the '%s' logging level (or lower)", EFFUSIVE) |
| 962 | EFFUSIVE:root:This should only be seen at the '7' logging level (or lower) |
| 963 | |
| 964 | >>> log.log(8, "This should only be seen at the '%s' logging level (or lower)", TERSE) |
| 965 | TERSE:root:This should only be seen at the '8' logging level (or lower) |
| 966 | |
| 967 | >>> log.log(9, "This should only be seen at the '%s' logging level (or lower)", TACITURN) |
| 968 | TACITURN:root:This should only be seen at the '9' logging level (or lower) |
| 969 | |
| 970 | >>> log.log(10, "This should only be seen at the '%s' logging level (or lower)", SILENT) |
| 971 | SILENT:root:This should only be seen at the '10' logging level (or lower) |
| 972 | |
| 973 | >>> log.setLevel(7) |
| 974 | |
| 975 | >>> log.log(1, "This should only be seen at the '%s' logging level (or lower)", BORING) |
| 976 | |
| 977 | >>> log.log(2, "This should only be seen at the '%s' logging level (or lower)", CHATTERBOX) |
| 978 | |
| 979 | >>> log.log(3, "This should only be seen at the '%s' logging level (or lower)", GARRULOUS) |
| 980 | |
| 981 | >>> log.log(4, "This should only be seen at the '%s' logging level (or lower)", TALKATIVE) |
| 982 | |
| 983 | >>> log.log(5, "This should only be seen at the '%s' logging level (or lower)", VERBOSE) |
| 984 | |
| 985 | >>> log.log(6, "This should only be seen at the '%s' logging level (or lower)", SOCIABLE) |
| 986 | |
| 987 | >>> log.log(7, "This should only be seen at the '%s' logging level (or lower)", EFFUSIVE) |
| 988 | EFFUSIVE:root:This should only be seen at the '7' logging level (or lower) |
| 989 | |
| 990 | >>> log.log(8, "This should only be seen at the '%s' logging level (or lower)", TERSE) |
| 991 | TERSE:root:This should only be seen at the '8' logging level (or lower) |
| 992 | |
| 993 | >>> log.log(9, "This should only be seen at the '%s' logging level (or lower)", TACITURN) |
| 994 | TACITURN:root:This should only be seen at the '9' logging level (or lower) |
| 995 | |
| 996 | >>> log.log(10, "This should only be seen at the '%s' logging level (or lower)", SILENT) |
| 997 | SILENT:root:This should only be seen at the '10' logging level (or lower) |
| 998 | |
| 999 | >>> log.setLevel(8) |
| 1000 | |
| 1001 | >>> log.log(1, "This should only be seen at the '%s' logging level (or lower)", BORING) |
| 1002 | |
| 1003 | >>> log.log(2, "This should only be seen at the '%s' logging level (or lower)", CHATTERBOX) |
| 1004 | |
| 1005 | >>> log.log(3, "This should only be seen at the '%s' logging level (or lower)", GARRULOUS) |
| 1006 | |
| 1007 | >>> log.log(4, "This should only be seen at the '%s' logging level (or lower)", TALKATIVE) |
| 1008 | |
| 1009 | >>> log.log(5, "This should only be seen at the '%s' logging level (or lower)", VERBOSE) |
| 1010 | |
| 1011 | >>> log.log(6, "This should only be seen at the '%s' logging level (or lower)", SOCIABLE) |
| 1012 | |
| 1013 | >>> log.log(7, "This should only be seen at the '%s' logging level (or lower)", EFFUSIVE) |
| 1014 | |
| 1015 | >>> log.log(8, "This should only be seen at the '%s' logging level (or lower)", TERSE) |
| 1016 | TERSE:root:This should only be seen at the '8' logging level (or lower) |
| 1017 | |
| 1018 | >>> log.log(9, "This should only be seen at the '%s' logging level (or lower)", TACITURN) |
| 1019 | TACITURN:root:This should only be seen at the '9' logging level (or lower) |
| 1020 | |
| 1021 | >>> log.log(10, "This should only be seen at the '%s' logging level (or lower)", SILENT) |
| 1022 | SILENT:root:This should only be seen at the '10' logging level (or lower) |
| 1023 | |
| 1024 | >>> log.setLevel(9) |
| 1025 | |
| 1026 | >>> log.log(1, "This should only be seen at the '%s' logging level (or lower)", BORING) |
| 1027 | |
| 1028 | >>> log.log(2, "This should only be seen at the '%s' logging level (or lower)", CHATTERBOX) |
| 1029 | |
| 1030 | >>> log.log(3, "This should only be seen at the '%s' logging level (or lower)", GARRULOUS) |
| 1031 | |
| 1032 | >>> log.log(4, "This should only be seen at the '%s' logging level (or lower)", TALKATIVE) |
| 1033 | |
| 1034 | >>> log.log(5, "This should only be seen at the '%s' logging level (or lower)", VERBOSE) |
| 1035 | |
| 1036 | >>> log.log(6, "This should only be seen at the '%s' logging level (or lower)", SOCIABLE) |
| 1037 | |
| 1038 | >>> log.log(7, "This should only be seen at the '%s' logging level (or lower)", EFFUSIVE) |
| 1039 | |
| 1040 | >>> log.log(8, "This should only be seen at the '%s' logging level (or lower)", TERSE) |
| 1041 | |
| 1042 | >>> log.log(9, "This should only be seen at the '%s' logging level (or lower)", TACITURN) |
| 1043 | TACITURN:root:This should only be seen at the '9' logging level (or lower) |
| 1044 | |
| 1045 | >>> log.log(10, "This should only be seen at the '%s' logging level (or lower)", SILENT) |
| 1046 | SILENT:root:This should only be seen at the '10' logging level (or lower) |
| 1047 | |
| 1048 | >>> log.setLevel(10) |
| 1049 | |
| 1050 | >>> log.log(1, "This should only be seen at the '%s' logging level (or lower)", BORING) |
| 1051 | |
| 1052 | >>> log.log(2, "This should only be seen at the '%s' logging level (or lower)", CHATTERBOX) |
| 1053 | |
| 1054 | >>> log.log(3, "This should only be seen at the '%s' logging level (or lower)", GARRULOUS) |
| 1055 | |
| 1056 | >>> log.log(4, "This should only be seen at the '%s' logging level (or lower)", TALKATIVE) |
| 1057 | |
| 1058 | >>> log.log(5, "This should only be seen at the '%s' logging level (or lower)", VERBOSE) |
| 1059 | |
| 1060 | >>> log.log(6, "This should only be seen at the '%s' logging level (or lower)", SOCIABLE) |
| 1061 | |
| 1062 | >>> log.log(7, "This should only be seen at the '%s' logging level (or lower)", EFFUSIVE) |
| 1063 | |
| 1064 | >>> log.log(8, "This should only be seen at the '%s' logging level (or lower)", TERSE) |
| 1065 | |
| 1066 | >>> log.log(9, "This should only be seen at the '%s' logging level (or lower)", TACITURN) |
| 1067 | |
| 1068 | >>> log.log(10, "This should only be seen at the '%s' logging level (or lower)", SILENT) |
| 1069 | SILENT:root:This should only be seen at the '10' logging level (or lower) |
| 1070 | |
| 1071 | >>> spec = VerySpecificFilter() |
| 1072 | |
| 1073 | >>> log.addFilter(spec) |
| 1074 | |
| 1075 | >>> log.setLevel(1) |
| 1076 | |
| 1077 | >>> log.log(1, "This should only be seen at the '%s' logging level (or lower)", BORING) |
| 1078 | BORING:root:This should only be seen at the '1' logging level (or lower) |
| 1079 | |
| 1080 | >>> log.log(2, "This should only be seen at the '%s' logging level (or lower)", CHATTERBOX) |
| 1081 | CHATTERBOX:root:This should only be seen at the '2' logging level (or lower) |
| 1082 | |
| 1083 | >>> log.log(3, "This should only be seen at the '%s' logging level (or lower)", GARRULOUS) |
| 1084 | |
| 1085 | >>> log.log(4, "This should only be seen at the '%s' logging level (or lower)", TALKATIVE) |
| 1086 | TALKATIVE:root:This should only be seen at the '4' logging level (or lower) |
| 1087 | |
| 1088 | >>> log.log(5, "This should only be seen at the '%s' logging level (or lower)", VERBOSE) |
| 1089 | VERBOSE:root:This should only be seen at the '5' logging level (or lower) |
| 1090 | |
| 1091 | >>> log.log(6, "This should only be seen at the '%s' logging level (or lower)", SOCIABLE) |
| 1092 | |
| 1093 | >>> log.log(7, "This should only be seen at the '%s' logging level (or lower)", EFFUSIVE) |
| 1094 | EFFUSIVE:root:This should only be seen at the '7' logging level (or lower) |
| 1095 | |
| 1096 | >>> log.log(8, "This should only be seen at the '%s' logging level (or lower)", TERSE) |
| 1097 | TERSE:root:This should only be seen at the '8' logging level (or lower) |
| 1098 | |
| 1099 | >>> log.log(9, "This should only be seen at the '%s' logging level (or lower)", TACITURN) |
| 1100 | |
| 1101 | >>> log.log(10, "This should only be seen at the '%s' logging level (or lower)", SILENT) |
| 1102 | SILENT:root:This should only be seen at the '10' logging level (or lower) |
| 1103 | |
| 1104 | >>> log.setLevel(2) |
| 1105 | |
| 1106 | >>> log.log(1, "This should only be seen at the '%s' logging level (or lower)", BORING) |
| 1107 | |
| 1108 | >>> log.log(2, "This should only be seen at the '%s' logging level (or lower)", CHATTERBOX) |
| 1109 | CHATTERBOX:root:This should only be seen at the '2' logging level (or lower) |
| 1110 | |
| 1111 | >>> log.log(3, "This should only be seen at the '%s' logging level (or lower)", GARRULOUS) |
| 1112 | |
| 1113 | >>> log.log(4, "This should only be seen at the '%s' logging level (or lower)", TALKATIVE) |
| 1114 | TALKATIVE:root:This should only be seen at the '4' logging level (or lower) |
| 1115 | |
| 1116 | >>> log.log(5, "This should only be seen at the '%s' logging level (or lower)", VERBOSE) |
| 1117 | VERBOSE:root:This should only be seen at the '5' logging level (or lower) |
| 1118 | |
| 1119 | >>> log.log(6, "This should only be seen at the '%s' logging level (or lower)", SOCIABLE) |
| 1120 | |
| 1121 | >>> log.log(7, "This should only be seen at the '%s' logging level (or lower)", EFFUSIVE) |
| 1122 | EFFUSIVE:root:This should only be seen at the '7' logging level (or lower) |
| 1123 | |
| 1124 | >>> log.log(8, "This should only be seen at the '%s' logging level (or lower)", TERSE) |
| 1125 | TERSE:root:This should only be seen at the '8' logging level (or lower) |
| 1126 | |
| 1127 | >>> log.log(9, "This should only be seen at the '%s' logging level (or lower)", TACITURN) |
| 1128 | |
| 1129 | >>> log.log(10, "This should only be seen at the '%s' logging level (or lower)", SILENT) |
| 1130 | SILENT:root:This should only be seen at the '10' logging level (or lower) |
| 1131 | |
| 1132 | >>> log.setLevel(3) |
| 1133 | |
| 1134 | >>> log.log(1, "This should only be seen at the '%s' logging level (or lower)", BORING) |
| 1135 | |
| 1136 | >>> log.log(2, "This should only be seen at the '%s' logging level (or lower)", CHATTERBOX) |
| 1137 | |
| 1138 | >>> log.log(3, "This should only be seen at the '%s' logging level (or lower)", GARRULOUS) |
| 1139 | |
| 1140 | >>> log.log(4, "This should only be seen at the '%s' logging level (or lower)", TALKATIVE) |
| 1141 | TALKATIVE:root:This should only be seen at the '4' logging level (or lower) |
| 1142 | |
| 1143 | >>> log.log(5, "This should only be seen at the '%s' logging level (or lower)", VERBOSE) |
| 1144 | VERBOSE:root:This should only be seen at the '5' logging level (or lower) |
| 1145 | |
| 1146 | >>> log.log(6, "This should only be seen at the '%s' logging level (or lower)", SOCIABLE) |
| 1147 | |
| 1148 | >>> log.log(7, "This should only be seen at the '%s' logging level (or lower)", EFFUSIVE) |
| 1149 | EFFUSIVE:root:This should only be seen at the '7' logging level (or lower) |
| 1150 | |
| 1151 | >>> log.log(8, "This should only be seen at the '%s' logging level (or lower)", TERSE) |
| 1152 | TERSE:root:This should only be seen at the '8' logging level (or lower) |
| 1153 | |
| 1154 | >>> log.log(9, "This should only be seen at the '%s' logging level (or lower)", TACITURN) |
| 1155 | |
| 1156 | >>> log.log(10, "This should only be seen at the '%s' logging level (or lower)", SILENT) |
| 1157 | SILENT:root:This should only be seen at the '10' logging level (or lower) |
| 1158 | |
| 1159 | >>> log.setLevel(4) |
| 1160 | |
| 1161 | >>> log.log(1, "This should only be seen at the '%s' logging level (or lower)", BORING) |
| 1162 | |
| 1163 | >>> log.log(2, "This should only be seen at the '%s' logging level (or lower)", CHATTERBOX) |
| 1164 | |
| 1165 | >>> log.log(3, "This should only be seen at the '%s' logging level (or lower)", GARRULOUS) |
| 1166 | |
| 1167 | >>> log.log(4, "This should only be seen at the '%s' logging level (or lower)", TALKATIVE) |
| 1168 | TALKATIVE:root:This should only be seen at the '4' logging level (or lower) |
| 1169 | |
| 1170 | >>> log.log(5, "This should only be seen at the '%s' logging level (or lower)", VERBOSE) |
| 1171 | VERBOSE:root:This should only be seen at the '5' logging level (or lower) |
| 1172 | |
| 1173 | >>> log.log(6, "This should only be seen at the '%s' logging level (or lower)", SOCIABLE) |
| 1174 | |
| 1175 | >>> log.log(7, "This should only be seen at the '%s' logging level (or lower)", EFFUSIVE) |
| 1176 | EFFUSIVE:root:This should only be seen at the '7' logging level (or lower) |
| 1177 | |
| 1178 | >>> log.log(8, "This should only be seen at the '%s' logging level (or lower)", TERSE) |
| 1179 | TERSE:root:This should only be seen at the '8' logging level (or lower) |
| 1180 | |
| 1181 | >>> log.log(9, "This should only be seen at the '%s' logging level (or lower)", TACITURN) |
| 1182 | |
| 1183 | >>> log.log(10, "This should only be seen at the '%s' logging level (or lower)", SILENT) |
| 1184 | SILENT:root:This should only be seen at the '10' logging level (or lower) |
| 1185 | |
| 1186 | >>> log.setLevel(5) |
| 1187 | |
| 1188 | >>> log.log(1, "This should only be seen at the '%s' logging level (or lower)", BORING) |
| 1189 | |
| 1190 | >>> log.log(2, "This should only be seen at the '%s' logging level (or lower)", CHATTERBOX) |
| 1191 | |
| 1192 | >>> log.log(3, "This should only be seen at the '%s' logging level (or lower)", GARRULOUS) |
| 1193 | |
| 1194 | >>> log.log(4, "This should only be seen at the '%s' logging level (or lower)", TALKATIVE) |
| 1195 | |
| 1196 | >>> log.log(5, "This should only be seen at the '%s' logging level (or lower)", VERBOSE) |
| 1197 | VERBOSE:root:This should only be seen at the '5' logging level (or lower) |
| 1198 | |
| 1199 | >>> log.log(6, "This should only be seen at the '%s' logging level (or lower)", SOCIABLE) |
| 1200 | |
| 1201 | >>> log.log(7, "This should only be seen at the '%s' logging level (or lower)", EFFUSIVE) |
| 1202 | EFFUSIVE:root:This should only be seen at the '7' logging level (or lower) |
| 1203 | |
| 1204 | >>> log.log(8, "This should only be seen at the '%s' logging level (or lower)", TERSE) |
| 1205 | TERSE:root:This should only be seen at the '8' logging level (or lower) |
| 1206 | |
| 1207 | >>> log.log(9, "This should only be seen at the '%s' logging level (or lower)", TACITURN) |
| 1208 | |
| 1209 | >>> log.log(10, "This should only be seen at the '%s' logging level (or lower)", SILENT) |
| 1210 | SILENT:root:This should only be seen at the '10' logging level (or lower) |
| 1211 | |
| 1212 | >>> log.setLevel(6) |
| 1213 | |
| 1214 | >>> log.log(1, "This should only be seen at the '%s' logging level (or lower)", BORING) |
| 1215 | |
| 1216 | >>> log.log(2, "This should only be seen at the '%s' logging level (or lower)", CHATTERBOX) |
| 1217 | |
| 1218 | >>> log.log(3, "This should only be seen at the '%s' logging level (or lower)", GARRULOUS) |
| 1219 | |
| 1220 | >>> log.log(4, "This should only be seen at the '%s' logging level (or lower)", TALKATIVE) |
| 1221 | |
| 1222 | >>> log.log(5, "This should only be seen at the '%s' logging level (or lower)", VERBOSE) |
| 1223 | |
| 1224 | >>> log.log(6, "This should only be seen at the '%s' logging level (or lower)", SOCIABLE) |
| 1225 | |
| 1226 | >>> log.log(7, "This should only be seen at the '%s' logging level (or lower)", EFFUSIVE) |
| 1227 | EFFUSIVE:root:This should only be seen at the '7' logging level (or lower) |
| 1228 | |
| 1229 | >>> log.log(8, "This should only be seen at the '%s' logging level (or lower)", TERSE) |
| 1230 | TERSE:root:This should only be seen at the '8' logging level (or lower) |
| 1231 | |
| 1232 | >>> log.log(9, "This should only be seen at the '%s' logging level (or lower)", TACITURN) |
| 1233 | |
| 1234 | >>> log.log(10, "This should only be seen at the '%s' logging level (or lower)", SILENT) |
| 1235 | SILENT:root:This should only be seen at the '10' logging level (or lower) |
| 1236 | |
| 1237 | >>> log.setLevel(7) |
| 1238 | |
| 1239 | >>> log.log(1, "This should only be seen at the '%s' logging level (or lower)", BORING) |
| 1240 | |
| 1241 | >>> log.log(2, "This should only be seen at the '%s' logging level (or lower)", CHATTERBOX) |
| 1242 | |
| 1243 | >>> log.log(3, "This should only be seen at the '%s' logging level (or lower)", GARRULOUS) |
| 1244 | |
| 1245 | >>> log.log(4, "This should only be seen at the '%s' logging level (or lower)", TALKATIVE) |
| 1246 | |
| 1247 | >>> log.log(5, "This should only be seen at the '%s' logging level (or lower)", VERBOSE) |
| 1248 | |
| 1249 | >>> log.log(6, "This should only be seen at the '%s' logging level (or lower)", SOCIABLE) |
| 1250 | |
| 1251 | >>> log.log(7, "This should only be seen at the '%s' logging level (or lower)", EFFUSIVE) |
| 1252 | EFFUSIVE:root:This should only be seen at the '7' logging level (or lower) |
| 1253 | |
| 1254 | >>> log.log(8, "This should only be seen at the '%s' logging level (or lower)", TERSE) |
| 1255 | TERSE:root:This should only be seen at the '8' logging level (or lower) |
| 1256 | |
| 1257 | >>> log.log(9, "This should only be seen at the '%s' logging level (or lower)", TACITURN) |
| 1258 | |
| 1259 | >>> log.log(10, "This should only be seen at the '%s' logging level (or lower)", SILENT) |
| 1260 | SILENT:root:This should only be seen at the '10' logging level (or lower) |
| 1261 | |
| 1262 | >>> log.setLevel(8) |
| 1263 | |
| 1264 | >>> log.log(1, "This should only be seen at the '%s' logging level (or lower)", BORING) |
| 1265 | |
| 1266 | >>> log.log(2, "This should only be seen at the '%s' logging level (or lower)", CHATTERBOX) |
| 1267 | |
| 1268 | >>> log.log(3, "This should only be seen at the '%s' logging level (or lower)", GARRULOUS) |
| 1269 | |
| 1270 | >>> log.log(4, "This should only be seen at the '%s' logging level (or lower)", TALKATIVE) |
| 1271 | |
| 1272 | >>> log.log(5, "This should only be seen at the '%s' logging level (or lower)", VERBOSE) |
| 1273 | |
| 1274 | >>> log.log(6, "This should only be seen at the '%s' logging level (or lower)", SOCIABLE) |
| 1275 | |
| 1276 | >>> log.log(7, "This should only be seen at the '%s' logging level (or lower)", EFFUSIVE) |
| 1277 | |
| 1278 | >>> log.log(8, "This should only be seen at the '%s' logging level (or lower)", TERSE) |
| 1279 | TERSE:root:This should only be seen at the '8' logging level (or lower) |
| 1280 | |
| 1281 | >>> log.log(9, "This should only be seen at the '%s' logging level (or lower)", TACITURN) |
| 1282 | |
| 1283 | >>> log.log(10, "This should only be seen at the '%s' logging level (or lower)", SILENT) |
| 1284 | SILENT:root:This should only be seen at the '10' logging level (or lower) |
| 1285 | |
| 1286 | >>> log.setLevel(9) |
| 1287 | |
| 1288 | >>> log.log(1, "This should only be seen at the '%s' logging level (or lower)", BORING) |
| 1289 | |
| 1290 | >>> log.log(2, "This should only be seen at the '%s' logging level (or lower)", CHATTERBOX) |
| 1291 | |
| 1292 | >>> log.log(3, "This should only be seen at the '%s' logging level (or lower)", GARRULOUS) |
| 1293 | |
| 1294 | >>> log.log(4, "This should only be seen at the '%s' logging level (or lower)", TALKATIVE) |
| 1295 | |
| 1296 | >>> log.log(5, "This should only be seen at the '%s' logging level (or lower)", VERBOSE) |
| 1297 | |
| 1298 | >>> log.log(6, "This should only be seen at the '%s' logging level (or lower)", SOCIABLE) |
| 1299 | |
| 1300 | >>> log.log(7, "This should only be seen at the '%s' logging level (or lower)", EFFUSIVE) |
| 1301 | |
| 1302 | >>> log.log(8, "This should only be seen at the '%s' logging level (or lower)", TERSE) |
| 1303 | |
| 1304 | >>> log.log(9, "This should only be seen at the '%s' logging level (or lower)", TACITURN) |
| 1305 | |
| 1306 | >>> log.log(10, "This should only be seen at the '%s' logging level (or lower)", SILENT) |
| 1307 | SILENT:root:This should only be seen at the '10' logging level (or lower) |
| 1308 | |
| 1309 | >>> log.setLevel(10) |
| 1310 | |
| 1311 | >>> log.log(1, "This should only be seen at the '%s' logging level (or lower)", BORING) |
| 1312 | |
| 1313 | >>> log.log(2, "This should only be seen at the '%s' logging level (or lower)", CHATTERBOX) |
| 1314 | |
| 1315 | >>> log.log(3, "This should only be seen at the '%s' logging level (or lower)", GARRULOUS) |
| 1316 | |
| 1317 | >>> log.log(4, "This should only be seen at the '%s' logging level (or lower)", TALKATIVE) |
| 1318 | |
| 1319 | >>> log.log(5, "This should only be seen at the '%s' logging level (or lower)", VERBOSE) |
| 1320 | |
| 1321 | >>> log.log(6, "This should only be seen at the '%s' logging level (or lower)", SOCIABLE) |
| 1322 | |
| 1323 | >>> log.log(7, "This should only be seen at the '%s' logging level (or lower)", EFFUSIVE) |
| 1324 | |
| 1325 | >>> log.log(8, "This should only be seen at the '%s' logging level (or lower)", TERSE) |
| 1326 | |
| 1327 | >>> log.log(9, "This should only be seen at the '%s' logging level (or lower)", TACITURN) |
| 1328 | |
| 1329 | >>> log.log(10, "This should only be seen at the '%s' logging level (or lower)", SILENT) |
| 1330 | SILENT:root:This should only be seen at the '10' logging level (or lower) |
| 1331 | |
| 1332 | >>> log.setLevel(0) |
| 1333 | |
| 1334 | >>> log.removeFilter(spec) |
| 1335 | |
| 1336 | >>> hdlr.removeFilter(garr) |
| 1337 | |
| 1338 | >>> logging.addLevelName(logging.DEBUG, "DEBUG") |
| 1339 | |
| 1340 | |
| 1341 | Test 2 |
| 1342 | ====== |
| 1343 | Test memory handlers. These are basically buffers for log messages: they take so many messages, and then print them all. |
| 1344 | |
| 1345 | >>> import logging.handlers |
| 1346 | |
| 1347 | >>> sys.stderr = sys.stdout |
| 1348 | >>> logger = logging.getLogger("") |
| 1349 | >>> sh = logger.handlers[0] |
| 1350 | >>> sh.close() |
| 1351 | >>> logger.removeHandler(sh) |
| 1352 | >>> mh = logging.handlers.MemoryHandler(10,logging.WARNING, sh) |
| 1353 | >>> logger.setLevel(logging.DEBUG) |
| 1354 | >>> logger.addHandler(mh) |
| 1355 | |
| 1356 | >>> logger.debug("Debug message") |
| 1357 | |
| 1358 | -- logging at INFO, nothing should be seen yet -- |
| 1359 | |
| 1360 | >>> logger.info("Info message") |
| 1361 | |
| 1362 | -- logging at WARNING, 3 messages should be seen -- |
| 1363 | |
| 1364 | >>> logger.warn("Warn message") |
| 1365 | DEBUG:root:Debug message |
| 1366 | INFO:root:Info message |
| 1367 | WARNING:root:Warn message |
| 1368 | |
| 1369 | >>> logger.info("Info index = 0") |
| 1370 | |
| 1371 | >>> logger.info("Info index = 1") |
| 1372 | |
| 1373 | >>> logger.info("Info index = 2") |
| 1374 | |
| 1375 | >>> logger.info("Info index = 3") |
| 1376 | |
| 1377 | >>> logger.info("Info index = 4") |
| 1378 | |
| 1379 | >>> logger.info("Info index = 5") |
| 1380 | |
| 1381 | >>> logger.info("Info index = 6") |
| 1382 | |
| 1383 | >>> logger.info("Info index = 7") |
| 1384 | |
| 1385 | >>> logger.info("Info index = 8") |
| 1386 | |
| 1387 | >>> logger.info("Info index = 9") |
| 1388 | INFO:root:Info index = 0 |
| 1389 | INFO:root:Info index = 1 |
| 1390 | INFO:root:Info index = 2 |
| 1391 | INFO:root:Info index = 3 |
| 1392 | INFO:root:Info index = 4 |
| 1393 | INFO:root:Info index = 5 |
| 1394 | INFO:root:Info index = 6 |
| 1395 | INFO:root:Info index = 7 |
| 1396 | INFO:root:Info index = 8 |
| 1397 | INFO:root:Info index = 9 |
| 1398 | |
| 1399 | >>> logger.info("Info index = 10") |
| 1400 | |
| 1401 | >>> logger.info("Info index = 11") |
| 1402 | |
| 1403 | >>> logger.info("Info index = 12") |
| 1404 | |
| 1405 | >>> logger.info("Info index = 13") |
| 1406 | |
| 1407 | >>> logger.info("Info index = 14") |
| 1408 | |
| 1409 | >>> logger.info("Info index = 15") |
| 1410 | |
| 1411 | >>> logger.info("Info index = 16") |
| 1412 | |
| 1413 | >>> logger.info("Info index = 17") |
| 1414 | |
| 1415 | >>> logger.info("Info index = 18") |
| 1416 | |
| 1417 | >>> logger.info("Info index = 19") |
| 1418 | INFO:root:Info index = 10 |
| 1419 | INFO:root:Info index = 11 |
| 1420 | INFO:root:Info index = 12 |
| 1421 | INFO:root:Info index = 13 |
| 1422 | INFO:root:Info index = 14 |
| 1423 | INFO:root:Info index = 15 |
| 1424 | INFO:root:Info index = 16 |
| 1425 | INFO:root:Info index = 17 |
| 1426 | INFO:root:Info index = 18 |
| 1427 | INFO:root:Info index = 19 |
| 1428 | |
| 1429 | >>> logger.info("Info index = 20") |
| 1430 | |
| 1431 | >>> logger.info("Info index = 21") |
| 1432 | |
| 1433 | >>> logger.info("Info index = 22") |
| 1434 | |
| 1435 | >>> logger.info("Info index = 23") |
| 1436 | |
| 1437 | >>> logger.info("Info index = 24") |
| 1438 | |
| 1439 | >>> logger.info("Info index = 25") |
| 1440 | |
| 1441 | >>> logger.info("Info index = 26") |
| 1442 | |
| 1443 | >>> logger.info("Info index = 27") |
| 1444 | |
| 1445 | >>> logger.info("Info index = 28") |
| 1446 | |
| 1447 | >>> logger.info("Info index = 29") |
| 1448 | INFO:root:Info index = 20 |
| 1449 | INFO:root:Info index = 21 |
| 1450 | INFO:root:Info index = 22 |
| 1451 | INFO:root:Info index = 23 |
| 1452 | INFO:root:Info index = 24 |
| 1453 | INFO:root:Info index = 25 |
| 1454 | INFO:root:Info index = 26 |
| 1455 | INFO:root:Info index = 27 |
| 1456 | INFO:root:Info index = 28 |
| 1457 | INFO:root:Info index = 29 |
| 1458 | |
| 1459 | >>> logger.info("Info index = 30") |
| 1460 | |
| 1461 | >>> logger.info("Info index = 31") |
| 1462 | |
| 1463 | >>> logger.info("Info index = 32") |
| 1464 | |
| 1465 | >>> logger.info("Info index = 33") |
| 1466 | |
| 1467 | >>> logger.info("Info index = 34") |
| 1468 | |
| 1469 | >>> logger.info("Info index = 35") |
| 1470 | |
| 1471 | >>> logger.info("Info index = 36") |
| 1472 | |
| 1473 | >>> logger.info("Info index = 37") |
| 1474 | |
| 1475 | >>> logger.info("Info index = 38") |
| 1476 | |
| 1477 | >>> logger.info("Info index = 39") |
| 1478 | INFO:root:Info index = 30 |
| 1479 | INFO:root:Info index = 31 |
| 1480 | INFO:root:Info index = 32 |
| 1481 | INFO:root:Info index = 33 |
| 1482 | INFO:root:Info index = 34 |
| 1483 | INFO:root:Info index = 35 |
| 1484 | INFO:root:Info index = 36 |
| 1485 | INFO:root:Info index = 37 |
| 1486 | INFO:root:Info index = 38 |
| 1487 | INFO:root:Info index = 39 |
| 1488 | |
| 1489 | >>> logger.info("Info index = 40") |
| 1490 | |
| 1491 | >>> logger.info("Info index = 41") |
| 1492 | |
| 1493 | >>> logger.info("Info index = 42") |
| 1494 | |
| 1495 | >>> logger.info("Info index = 43") |
| 1496 | |
| 1497 | >>> logger.info("Info index = 44") |
| 1498 | |
| 1499 | >>> logger.info("Info index = 45") |
| 1500 | |
| 1501 | >>> logger.info("Info index = 46") |
| 1502 | |
| 1503 | >>> logger.info("Info index = 47") |
| 1504 | |
| 1505 | >>> logger.info("Info index = 48") |
| 1506 | |
| 1507 | >>> logger.info("Info index = 49") |
| 1508 | INFO:root:Info index = 40 |
| 1509 | INFO:root:Info index = 41 |
| 1510 | INFO:root:Info index = 42 |
| 1511 | INFO:root:Info index = 43 |
| 1512 | INFO:root:Info index = 44 |
| 1513 | INFO:root:Info index = 45 |
| 1514 | INFO:root:Info index = 46 |
| 1515 | INFO:root:Info index = 47 |
| 1516 | INFO:root:Info index = 48 |
| 1517 | INFO:root:Info index = 49 |
| 1518 | |
| 1519 | >>> logger.info("Info index = 50") |
| 1520 | |
| 1521 | >>> logger.info("Info index = 51") |
| 1522 | |
| 1523 | >>> logger.info("Info index = 52") |
| 1524 | |
| 1525 | >>> logger.info("Info index = 53") |
| 1526 | |
| 1527 | >>> logger.info("Info index = 54") |
| 1528 | |
| 1529 | >>> logger.info("Info index = 55") |
| 1530 | |
| 1531 | >>> logger.info("Info index = 56") |
| 1532 | |
| 1533 | >>> logger.info("Info index = 57") |
| 1534 | |
| 1535 | >>> logger.info("Info index = 58") |
| 1536 | |
| 1537 | >>> logger.info("Info index = 59") |
| 1538 | INFO:root:Info index = 50 |
| 1539 | INFO:root:Info index = 51 |
| 1540 | INFO:root:Info index = 52 |
| 1541 | INFO:root:Info index = 53 |
| 1542 | INFO:root:Info index = 54 |
| 1543 | INFO:root:Info index = 55 |
| 1544 | INFO:root:Info index = 56 |
| 1545 | INFO:root:Info index = 57 |
| 1546 | INFO:root:Info index = 58 |
| 1547 | INFO:root:Info index = 59 |
| 1548 | |
| 1549 | >>> logger.info("Info index = 60") |
| 1550 | |
| 1551 | >>> logger.info("Info index = 61") |
| 1552 | |
| 1553 | >>> logger.info("Info index = 62") |
| 1554 | |
| 1555 | >>> logger.info("Info index = 63") |
| 1556 | |
| 1557 | >>> logger.info("Info index = 64") |
| 1558 | |
| 1559 | >>> logger.info("Info index = 65") |
| 1560 | |
| 1561 | >>> logger.info("Info index = 66") |
| 1562 | |
| 1563 | >>> logger.info("Info index = 67") |
| 1564 | |
| 1565 | >>> logger.info("Info index = 68") |
| 1566 | |
| 1567 | >>> logger.info("Info index = 69") |
| 1568 | INFO:root:Info index = 60 |
| 1569 | INFO:root:Info index = 61 |
| 1570 | INFO:root:Info index = 62 |
| 1571 | INFO:root:Info index = 63 |
| 1572 | INFO:root:Info index = 64 |
| 1573 | INFO:root:Info index = 65 |
| 1574 | INFO:root:Info index = 66 |
| 1575 | INFO:root:Info index = 67 |
| 1576 | INFO:root:Info index = 68 |
| 1577 | INFO:root:Info index = 69 |
| 1578 | |
| 1579 | >>> logger.info("Info index = 70") |
| 1580 | |
| 1581 | >>> logger.info("Info index = 71") |
| 1582 | |
| 1583 | >>> logger.info("Info index = 72") |
| 1584 | |
| 1585 | >>> logger.info("Info index = 73") |
| 1586 | |
| 1587 | >>> logger.info("Info index = 74") |
| 1588 | |
| 1589 | >>> logger.info("Info index = 75") |
| 1590 | |
| 1591 | >>> logger.info("Info index = 76") |
| 1592 | |
| 1593 | >>> logger.info("Info index = 77") |
| 1594 | |
| 1595 | >>> logger.info("Info index = 78") |
| 1596 | |
| 1597 | >>> logger.info("Info index = 79") |
| 1598 | INFO:root:Info index = 70 |
| 1599 | INFO:root:Info index = 71 |
| 1600 | INFO:root:Info index = 72 |
| 1601 | INFO:root:Info index = 73 |
| 1602 | INFO:root:Info index = 74 |
| 1603 | INFO:root:Info index = 75 |
| 1604 | INFO:root:Info index = 76 |
| 1605 | INFO:root:Info index = 77 |
| 1606 | INFO:root:Info index = 78 |
| 1607 | INFO:root:Info index = 79 |
| 1608 | |
| 1609 | >>> logger.info("Info index = 80") |
| 1610 | |
| 1611 | >>> logger.info("Info index = 81") |
| 1612 | |
| 1613 | >>> logger.info("Info index = 82") |
| 1614 | |
| 1615 | >>> logger.info("Info index = 83") |
| 1616 | |
| 1617 | >>> logger.info("Info index = 84") |
| 1618 | |
| 1619 | >>> logger.info("Info index = 85") |
| 1620 | |
| 1621 | >>> logger.info("Info index = 86") |
| 1622 | |
| 1623 | >>> logger.info("Info index = 87") |
| 1624 | |
| 1625 | >>> logger.info("Info index = 88") |
| 1626 | |
| 1627 | >>> logger.info("Info index = 89") |
| 1628 | INFO:root:Info index = 80 |
| 1629 | INFO:root:Info index = 81 |
| 1630 | INFO:root:Info index = 82 |
| 1631 | INFO:root:Info index = 83 |
| 1632 | INFO:root:Info index = 84 |
| 1633 | INFO:root:Info index = 85 |
| 1634 | INFO:root:Info index = 86 |
| 1635 | INFO:root:Info index = 87 |
| 1636 | INFO:root:Info index = 88 |
| 1637 | INFO:root:Info index = 89 |
| 1638 | |
| 1639 | >>> logger.info("Info index = 90") |
| 1640 | |
| 1641 | >>> logger.info("Info index = 91") |
| 1642 | |
| 1643 | >>> logger.info("Info index = 92") |
| 1644 | |
| 1645 | >>> logger.info("Info index = 93") |
| 1646 | |
| 1647 | >>> logger.info("Info index = 94") |
| 1648 | |
| 1649 | >>> logger.info("Info index = 95") |
| 1650 | |
| 1651 | >>> logger.info("Info index = 96") |
| 1652 | |
| 1653 | >>> logger.info("Info index = 97") |
| 1654 | |
| 1655 | >>> logger.info("Info index = 98") |
| 1656 | |
| 1657 | >>> logger.info("Info index = 99") |
| 1658 | INFO:root:Info index = 90 |
| 1659 | INFO:root:Info index = 91 |
| 1660 | INFO:root:Info index = 92 |
| 1661 | INFO:root:Info index = 93 |
| 1662 | INFO:root:Info index = 94 |
| 1663 | INFO:root:Info index = 95 |
| 1664 | INFO:root:Info index = 96 |
| 1665 | INFO:root:Info index = 97 |
| 1666 | INFO:root:Info index = 98 |
| 1667 | INFO:root:Info index = 99 |
| 1668 | |
| 1669 | >>> logger.info("Info index = 100") |
| 1670 | |
| 1671 | >>> logger.info("Info index = 101") |
| 1672 | |
| 1673 | >>> mh.close() |
| 1674 | INFO:root:Info index = 100 |
| 1675 | INFO:root:Info index = 101 |
| 1676 | |
| 1677 | >>> logger.removeHandler(mh) |
| 1678 | >>> logger.addHandler(sh) |
| 1679 | |
| 1680 | |
| 1681 | |
| 1682 | Test 3 |
| 1683 | ====== |
| 1684 | |
| 1685 | >>> import sys, logging |
| 1686 | >>> sys.stderr = sys |
| 1687 | >>> logging.basicConfig() |
| 1688 | >>> FILTER = "a.b" |
| 1689 | >>> root = logging.getLogger() |
| 1690 | >>> root.setLevel(logging.DEBUG) |
| 1691 | >>> hand = root.handlers[0] |
| 1692 | |
| 1693 | >>> logging.getLogger("a").info("Info 1") |
| 1694 | INFO:a:Info 1 |
| 1695 | |
| 1696 | >>> logging.getLogger("a.b").info("Info 2") |
| 1697 | INFO:a.b:Info 2 |
| 1698 | |
| 1699 | >>> logging.getLogger("a.c").info("Info 3") |
| 1700 | INFO:a.c:Info 3 |
| 1701 | |
| 1702 | >>> logging.getLogger("a.b.c").info("Info 4") |
| 1703 | INFO:a.b.c:Info 4 |
| 1704 | |
| 1705 | >>> logging.getLogger("a.b.c.d").info("Info 5") |
| 1706 | INFO:a.b.c.d:Info 5 |
| 1707 | |
| 1708 | >>> logging.getLogger("a.bb.c").info("Info 6") |
| 1709 | INFO:a.bb.c:Info 6 |
| 1710 | |
| 1711 | >>> logging.getLogger("b").info("Info 7") |
| 1712 | INFO:b:Info 7 |
| 1713 | |
| 1714 | >>> logging.getLogger("b.a").info("Info 8") |
| 1715 | INFO:b.a:Info 8 |
| 1716 | |
| 1717 | >>> logging.getLogger("c.a.b").info("Info 9") |
| 1718 | INFO:c.a.b:Info 9 |
| 1719 | |
| 1720 | >>> logging.getLogger("a.bb").info("Info 10") |
| 1721 | INFO:a.bb:Info 10 |
| 1722 | |
| 1723 | Filtered with 'a.b'... |
| 1724 | |
| 1725 | >>> filt = logging.Filter(FILTER) |
| 1726 | |
| 1727 | >>> hand.addFilter(filt) |
| 1728 | |
| 1729 | >>> logging.getLogger("a").info("Info 1") |
| 1730 | |
| 1731 | >>> logging.getLogger("a.b").info("Info 2") |
| 1732 | INFO:a.b:Info 2 |
| 1733 | |
| 1734 | >>> logging.getLogger("a.c").info("Info 3") |
| 1735 | |
| 1736 | >>> logging.getLogger("a.b.c").info("Info 4") |
| 1737 | INFO:a.b.c:Info 4 |
| 1738 | |
| 1739 | >>> logging.getLogger("a.b.c.d").info("Info 5") |
| 1740 | INFO:a.b.c.d:Info 5 |
| 1741 | |
| 1742 | >>> logging.getLogger("a.bb.c").info("Info 6") |
| 1743 | |
| 1744 | >>> logging.getLogger("b").info("Info 7") |
| 1745 | |
| 1746 | >>> logging.getLogger("b.a").info("Info 8") |
| 1747 | |
| 1748 | >>> logging.getLogger("c.a.b").info("Info 9") |
| 1749 | |
| 1750 | >>> logging.getLogger("a.bb").info("Info 10") |
| 1751 | |
| 1752 | >>> hand.removeFilter(filt) |
| 1753 | |
| 1754 | |
| 1755 | Test 4 |
| 1756 | ====== |
| 1757 | >>> import sys, logging, logging.handlers, string |
| 1758 | >>> import tempfile, logging.config, os, test.test_support |
| 1759 | >>> sys.stderr = sys.stdout |
| 1760 | |
| 1761 | >>> from test_logging import config0, config1 |
| 1762 | |
| 1763 | config2 has a subtle configuration error that should be reported |
| 1764 | >>> config2 = string.replace(config1, "sys.stdout", "sys.stbout") |
| 1765 | |
| 1766 | config3 has a less subtle configuration error |
| 1767 | >>> config3 = string.replace(config1, "formatter=form1", "formatter=misspelled_name") |
| 1768 | |
| 1769 | >>> def test4(conf): |
| 1770 | ... loggerDict = logging.getLogger().manager.loggerDict |
| 1771 | ... logging._acquireLock() |
| 1772 | ... try: |
| 1773 | ... saved_handlers = logging._handlers.copy() |
| 1774 | ... saved_handler_list = logging._handlerList[:] |
| 1775 | ... saved_loggers = loggerDict.copy() |
| 1776 | ... finally: |
| 1777 | ... logging._releaseLock() |
| 1778 | ... try: |
| 1779 | ... fn = test.test_support.TESTFN |
| 1780 | ... f = open(fn, "w") |
| 1781 | ... f.write(conf) |
| 1782 | ... f.close() |
| 1783 | ... try: |
| 1784 | ... logging.config.fileConfig(fn) |
| 1785 | ... #call again to make sure cleanup is correct |
| 1786 | ... logging.config.fileConfig(fn) |
| 1787 | ... except: |
| 1788 | ... t = sys.exc_info()[0] |
| 1789 | ... message(str(t)) |
| 1790 | ... else: |
| 1791 | ... message('ok.') |
| 1792 | ... os.remove(fn) |
| 1793 | ... finally: |
| 1794 | ... logging._acquireLock() |
| 1795 | ... try: |
| 1796 | ... logging._handlers.clear() |
| 1797 | ... logging._handlers.update(saved_handlers) |
| 1798 | ... logging._handlerList[:] = saved_handler_list |
| 1799 | ... loggerDict = logging.getLogger().manager.loggerDict |
| 1800 | ... loggerDict.clear() |
| 1801 | ... loggerDict.update(saved_loggers) |
| 1802 | ... finally: |
| 1803 | ... logging._releaseLock() |
| 1804 | |
| 1805 | >>> test4(config0) |
| 1806 | ok. |
| 1807 | |
| 1808 | >>> test4(config1) |
| 1809 | ok. |
| 1810 | |
| 1811 | >>> test4(config2) |
| 1812 | <type 'exceptions.AttributeError'> |
| 1813 | |
| 1814 | >>> test4(config3) |
| 1815 | <type 'exceptions.KeyError'> |
| 1816 | |
| 1817 | >>> import test_logging |
| 1818 | >>> test_logging.test5() |
| 1819 | ERROR:root:just testing |
| 1820 | <type 'exceptions.KeyError'>... Don't panic! |
| 1821 | |
| 1822 | |
| 1823 | Test Main |
| 1824 | ========= |
| 1825 | >>> import select |
| 1826 | >>> import os, sys, string, struct, types, cPickle, cStringIO |
| 1827 | >>> import socket, tempfile, threading, time |
| 1828 | >>> import logging, logging.handlers, logging.config |
| 1829 | >>> import test_logging |
| 1830 | |
| 1831 | >>> test_logging.test_main_inner() |
| 1832 | ERR -> CRITICAL: Message 0 (via logrecv.tcp.ERR) |
| 1833 | ERR -> ERROR: Message 1 (via logrecv.tcp.ERR) |
| 1834 | INF -> CRITICAL: Message 2 (via logrecv.tcp.INF) |
| 1835 | INF -> ERROR: Message 3 (via logrecv.tcp.INF) |
| 1836 | INF -> WARNING: Message 4 (via logrecv.tcp.INF) |
| 1837 | INF -> INFO: Message 5 (via logrecv.tcp.INF) |
| 1838 | INF.UNDEF -> CRITICAL: Message 6 (via logrecv.tcp.INF.UNDEF) |
| 1839 | INF.UNDEF -> ERROR: Message 7 (via logrecv.tcp.INF.UNDEF) |
| 1840 | INF.UNDEF -> WARNING: Message 8 (via logrecv.tcp.INF.UNDEF) |
| 1841 | INF.UNDEF -> INFO: Message 9 (via logrecv.tcp.INF.UNDEF) |
| 1842 | INF.ERR -> CRITICAL: Message 10 (via logrecv.tcp.INF.ERR) |
| 1843 | INF.ERR -> ERROR: Message 11 (via logrecv.tcp.INF.ERR) |
| 1844 | INF.ERR.UNDEF -> CRITICAL: Message 12 (via logrecv.tcp.INF.ERR.UNDEF) |
| 1845 | INF.ERR.UNDEF -> ERROR: Message 13 (via logrecv.tcp.INF.ERR.UNDEF) |
| 1846 | DEB -> CRITICAL: Message 14 (via logrecv.tcp.DEB) |
| 1847 | DEB -> ERROR: Message 15 (via logrecv.tcp.DEB) |
| 1848 | DEB -> WARNING: Message 16 (via logrecv.tcp.DEB) |
| 1849 | DEB -> INFO: Message 17 (via logrecv.tcp.DEB) |
| 1850 | DEB -> DEBUG: Message 18 (via logrecv.tcp.DEB) |
| 1851 | UNDEF -> CRITICAL: Message 19 (via logrecv.tcp.UNDEF) |
| 1852 | UNDEF -> ERROR: Message 20 (via logrecv.tcp.UNDEF) |
| 1853 | UNDEF -> WARNING: Message 21 (via logrecv.tcp.UNDEF) |
| 1854 | UNDEF -> INFO: Message 22 (via logrecv.tcp.UNDEF) |
| 1855 | INF.BADPARENT.UNDEF -> CRITICAL: Message 23 (via logrecv.tcp.INF.BADPARENT.UNDEF) |
| 1856 | INF.BADPARENT -> CRITICAL: Message 24 (via logrecv.tcp.INF.BADPARENT) |
| 1857 | INF -> INFO: Finish up, it's closing time. Messages should bear numbers 0 through 24. (via logrecv.tcp.INF) |
| 1858 | <BLANKLINE> |
| 1859 | """ |
Guido van Rossum | 2a1d516 | 2003-01-21 21:05:22 +0000 | [diff] [blame] | 1860 | import select |
Christian Heimes | c5f05e4 | 2008-02-23 17:40:11 +0000 | [diff] [blame] | 1861 | import os, sys, string, struct, cPickle, cStringIO |
| 1862 | import socket, threading |
Brett Cannon | f9db8a3 | 2008-02-17 01:59:18 +0000 | [diff] [blame] | 1863 | import logging, logging.handlers, logging.config, test.test_support |
| 1864 | |
Neal Norwitz | b4a2df0 | 2003-01-02 14:56:39 +0000 | [diff] [blame] | 1865 | |
Neal Norwitz | b4a2df0 | 2003-01-02 14:56:39 +0000 | [diff] [blame] | 1866 | BANNER = "-- %-10s %-6s ---------------------------------------------------\n" |
| 1867 | |
Guido van Rossum | 376e636 | 2003-04-25 14:22:00 +0000 | [diff] [blame] | 1868 | FINISH_UP = "Finish up, it's closing time. Messages should bear numbers 0 through 24." |
Brett Cannon | f9db8a3 | 2008-02-17 01:59:18 +0000 | [diff] [blame] | 1869 | #---------------------------------------------------------------------------- |
| 1870 | # Test 0 |
| 1871 | #---------------------------------------------------------------------------- |
| 1872 | |
| 1873 | msgcount = 0 |
| 1874 | |
| 1875 | def nextmessage(): |
| 1876 | global msgcount |
| 1877 | rv = "Message %d" % msgcount |
| 1878 | msgcount = msgcount + 1 |
| 1879 | return rv |
Guido van Rossum | 376e636 | 2003-04-25 14:22:00 +0000 | [diff] [blame] | 1880 | |
Neal Norwitz | b4a2df0 | 2003-01-02 14:56:39 +0000 | [diff] [blame] | 1881 | #---------------------------------------------------------------------------- |
| 1882 | # Log receiver |
| 1883 | #---------------------------------------------------------------------------- |
| 1884 | |
| 1885 | TIMEOUT = 10 |
| 1886 | |
| 1887 | from SocketServer import ThreadingTCPServer, StreamRequestHandler |
| 1888 | |
| 1889 | class LogRecordStreamHandler(StreamRequestHandler): |
| 1890 | """ |
| 1891 | Handler for a streaming logging request. It basically logs the record |
| 1892 | using whatever logging policy is configured locally. |
| 1893 | """ |
| 1894 | |
| 1895 | def handle(self): |
| 1896 | """ |
| 1897 | Handle multiple requests - each expected to be a 4-byte length, |
| 1898 | followed by the LogRecord in pickle format. Logs the record |
| 1899 | according to whatever policy is configured locally. |
| 1900 | """ |
| 1901 | while 1: |
| 1902 | try: |
| 1903 | chunk = self.connection.recv(4) |
| 1904 | if len(chunk) < 4: |
| 1905 | break |
| 1906 | slen = struct.unpack(">L", chunk)[0] |
Neal Norwitz | b4a2df0 | 2003-01-02 14:56:39 +0000 | [diff] [blame] | 1907 | chunk = self.connection.recv(slen) |
| 1908 | while len(chunk) < slen: |
| 1909 | chunk = chunk + self.connection.recv(slen - len(chunk)) |
| 1910 | obj = self.unPickle(chunk) |
Raymond Hettinger | 6f3eaa6 | 2003-06-27 21:43:39 +0000 | [diff] [blame] | 1911 | record = logging.makeLogRecord(obj) |
Neal Norwitz | b4a2df0 | 2003-01-02 14:56:39 +0000 | [diff] [blame] | 1912 | self.handleLogRecord(record) |
| 1913 | except: |
| 1914 | raise |
| 1915 | |
| 1916 | def unPickle(self, data): |
| 1917 | return cPickle.loads(data) |
| 1918 | |
| 1919 | def handleLogRecord(self, record): |
| 1920 | logname = "logrecv.tcp." + record.name |
Guido van Rossum | 376e636 | 2003-04-25 14:22:00 +0000 | [diff] [blame] | 1921 | #If the end-of-messages sentinel is seen, tell the server to terminate |
| 1922 | if record.msg == FINISH_UP: |
| 1923 | self.server.abort = 1 |
Neal Norwitz | b4a2df0 | 2003-01-02 14:56:39 +0000 | [diff] [blame] | 1924 | record.msg = record.msg + " (via " + logname + ")" |
Brett Cannon | f9db8a3 | 2008-02-17 01:59:18 +0000 | [diff] [blame] | 1925 | logger = logging.getLogger("logrecv") |
Neal Norwitz | b4a2df0 | 2003-01-02 14:56:39 +0000 | [diff] [blame] | 1926 | logger.handle(record) |
| 1927 | |
Brett Cannon | f9addb6 | 2003-04-30 05:32:32 +0000 | [diff] [blame] | 1928 | # The server sets socketDataProcessed when it's done. |
| 1929 | socketDataProcessed = threading.Event() |
Brett Cannon | f9db8a3 | 2008-02-17 01:59:18 +0000 | [diff] [blame] | 1930 | #---------------------------------------------------------------------------- |
| 1931 | # Test 5 |
| 1932 | #---------------------------------------------------------------------------- |
| 1933 | |
| 1934 | test5_config = """ |
| 1935 | [loggers] |
| 1936 | keys=root |
| 1937 | |
| 1938 | [handlers] |
| 1939 | keys=hand1 |
| 1940 | |
| 1941 | [formatters] |
| 1942 | keys=form1 |
| 1943 | |
| 1944 | [logger_root] |
| 1945 | level=NOTSET |
| 1946 | handlers=hand1 |
| 1947 | |
| 1948 | [handler_hand1] |
| 1949 | class=StreamHandler |
| 1950 | level=NOTSET |
| 1951 | formatter=form1 |
| 1952 | args=(sys.stdout,) |
| 1953 | |
| 1954 | [formatter_form1] |
| 1955 | class=test.test_logging.FriendlyFormatter |
| 1956 | format=%(levelname)s:%(name)s:%(message)s |
| 1957 | datefmt= |
| 1958 | """ |
| 1959 | |
| 1960 | class FriendlyFormatter (logging.Formatter): |
| 1961 | def formatException(self, ei): |
| 1962 | return "%s... Don't panic!" % str(ei[0]) |
| 1963 | |
| 1964 | |
| 1965 | def test5(): |
| 1966 | loggerDict = logging.getLogger().manager.loggerDict |
| 1967 | logging._acquireLock() |
| 1968 | try: |
| 1969 | saved_handlers = logging._handlers.copy() |
| 1970 | saved_handler_list = logging._handlerList[:] |
| 1971 | saved_loggers = loggerDict.copy() |
| 1972 | finally: |
| 1973 | logging._releaseLock() |
| 1974 | try: |
| 1975 | fn = test.test_support.TESTFN |
| 1976 | f = open(fn, "w") |
| 1977 | f.write(test5_config) |
| 1978 | f.close() |
| 1979 | logging.config.fileConfig(fn) |
| 1980 | try: |
| 1981 | raise KeyError |
| 1982 | except KeyError: |
| 1983 | logging.exception("just testing") |
| 1984 | os.remove(fn) |
| 1985 | hdlr = logging.getLogger().handlers[0] |
| 1986 | logging.getLogger().handlers.remove(hdlr) |
| 1987 | finally: |
| 1988 | logging._acquireLock() |
| 1989 | try: |
| 1990 | logging._handlers.clear() |
| 1991 | logging._handlers.update(saved_handlers) |
| 1992 | logging._handlerList[:] = saved_handler_list |
| 1993 | loggerDict = logging.getLogger().manager.loggerDict |
| 1994 | loggerDict.clear() |
| 1995 | loggerDict.update(saved_loggers) |
| 1996 | finally: |
| 1997 | logging._releaseLock() |
| 1998 | |
Guido van Rossum | 376e636 | 2003-04-25 14:22:00 +0000 | [diff] [blame] | 1999 | |
Neal Norwitz | b4a2df0 | 2003-01-02 14:56:39 +0000 | [diff] [blame] | 2000 | class LogRecordSocketReceiver(ThreadingTCPServer): |
| 2001 | """ |
| 2002 | A simple-minded TCP socket-based logging receiver suitable for test |
| 2003 | purposes. |
| 2004 | """ |
| 2005 | |
| 2006 | allow_reuse_address = 1 |
| 2007 | |
| 2008 | def __init__(self, host='localhost', |
| 2009 | port=logging.handlers.DEFAULT_TCP_LOGGING_PORT, |
| 2010 | handler=LogRecordStreamHandler): |
| 2011 | ThreadingTCPServer.__init__(self, (host, port), handler) |
Georg Brandl | 57826cf | 2008-02-23 15:06:25 +0000 | [diff] [blame] | 2012 | self.abort = False |
Neal Norwitz | b4a2df0 | 2003-01-02 14:56:39 +0000 | [diff] [blame] | 2013 | self.timeout = 1 |
| 2014 | |
| 2015 | def serve_until_stopped(self): |
Neal Norwitz | 55cd82f | 2006-02-05 08:21:08 +0000 | [diff] [blame] | 2016 | while not self.abort: |
Neal Norwitz | 5bab0f8 | 2006-03-05 02:16:12 +0000 | [diff] [blame] | 2017 | rd, wr, ex = select.select([self.socket.fileno()], [], [], |
| 2018 | self.timeout) |
| 2019 | if rd: |
| 2020 | self.handle_request() |
Georg Brandl | 57826cf | 2008-02-23 15:06:25 +0000 | [diff] [blame] | 2021 | socketDataProcessed.set() |
Martin v. Löwis | f684888 | 2006-01-29 19:55:18 +0000 | [diff] [blame] | 2022 | # close the listen socket |
| 2023 | self.server_close() |
Neal Norwitz | b4a2df0 | 2003-01-02 14:56:39 +0000 | [diff] [blame] | 2024 | |
Guido van Rossum | 2a1d516 | 2003-01-21 21:05:22 +0000 | [diff] [blame] | 2025 | def process_request(self, request, client_address): |
Guido van Rossum | 2a1d516 | 2003-01-21 21:05:22 +0000 | [diff] [blame] | 2026 | t = threading.Thread(target = self.finish_request, |
| 2027 | args = (request, client_address)) |
| 2028 | t.start() |
| 2029 | |
Neal Norwitz | b4a2df0 | 2003-01-02 14:56:39 +0000 | [diff] [blame] | 2030 | def runTCP(tcpserver): |
| 2031 | tcpserver.serve_until_stopped() |
| 2032 | |
Brett Cannon | f9db8a3 | 2008-02-17 01:59:18 +0000 | [diff] [blame] | 2033 | def banner(nm, typ): |
| 2034 | sep = BANNER % (nm, typ) |
| 2035 | sys.stdout.write(sep) |
| 2036 | sys.stdout.flush() |
Neal Norwitz | b4a2df0 | 2003-01-02 14:56:39 +0000 | [diff] [blame] | 2037 | |
| 2038 | def test0(): |
| 2039 | ERR = logging.getLogger("ERR") |
| 2040 | ERR.setLevel(logging.ERROR) |
| 2041 | INF = logging.getLogger("INF") |
| 2042 | INF.setLevel(logging.INFO) |
| 2043 | INF_ERR = logging.getLogger("INF.ERR") |
| 2044 | INF_ERR.setLevel(logging.ERROR) |
| 2045 | DEB = logging.getLogger("DEB") |
| 2046 | DEB.setLevel(logging.DEBUG) |
| 2047 | |
| 2048 | INF_UNDEF = logging.getLogger("INF.UNDEF") |
| 2049 | INF_ERR_UNDEF = logging.getLogger("INF.ERR.UNDEF") |
| 2050 | UNDEF = logging.getLogger("UNDEF") |
| 2051 | |
| 2052 | GRANDCHILD = logging.getLogger("INF.BADPARENT.UNDEF") |
| 2053 | CHILD = logging.getLogger("INF.BADPARENT") |
| 2054 | |
| 2055 | #These should log |
| 2056 | ERR.log(logging.FATAL, nextmessage()) |
| 2057 | ERR.error(nextmessage()) |
| 2058 | |
| 2059 | INF.log(logging.FATAL, nextmessage()) |
| 2060 | INF.error(nextmessage()) |
| 2061 | INF.warn(nextmessage()) |
| 2062 | INF.info(nextmessage()) |
| 2063 | |
| 2064 | INF_UNDEF.log(logging.FATAL, nextmessage()) |
| 2065 | INF_UNDEF.error(nextmessage()) |
| 2066 | INF_UNDEF.warn (nextmessage()) |
| 2067 | INF_UNDEF.info (nextmessage()) |
| 2068 | |
| 2069 | INF_ERR.log(logging.FATAL, nextmessage()) |
| 2070 | INF_ERR.error(nextmessage()) |
| 2071 | |
| 2072 | INF_ERR_UNDEF.log(logging.FATAL, nextmessage()) |
| 2073 | INF_ERR_UNDEF.error(nextmessage()) |
| 2074 | |
| 2075 | DEB.log(logging.FATAL, nextmessage()) |
| 2076 | DEB.error(nextmessage()) |
| 2077 | DEB.warn (nextmessage()) |
| 2078 | DEB.info (nextmessage()) |
| 2079 | DEB.debug(nextmessage()) |
| 2080 | |
| 2081 | UNDEF.log(logging.FATAL, nextmessage()) |
| 2082 | UNDEF.error(nextmessage()) |
| 2083 | UNDEF.warn (nextmessage()) |
| 2084 | UNDEF.info (nextmessage()) |
| 2085 | |
| 2086 | GRANDCHILD.log(logging.FATAL, nextmessage()) |
| 2087 | CHILD.log(logging.FATAL, nextmessage()) |
| 2088 | |
| 2089 | #These should not log |
| 2090 | ERR.warn(nextmessage()) |
| 2091 | ERR.info(nextmessage()) |
| 2092 | ERR.debug(nextmessage()) |
| 2093 | |
| 2094 | INF.debug(nextmessage()) |
| 2095 | INF_UNDEF.debug(nextmessage()) |
| 2096 | |
| 2097 | INF_ERR.warn(nextmessage()) |
| 2098 | INF_ERR.info(nextmessage()) |
| 2099 | INF_ERR.debug(nextmessage()) |
| 2100 | INF_ERR_UNDEF.warn(nextmessage()) |
| 2101 | INF_ERR_UNDEF.info(nextmessage()) |
| 2102 | INF_ERR_UNDEF.debug(nextmessage()) |
| 2103 | |
Guido van Rossum | 376e636 | 2003-04-25 14:22:00 +0000 | [diff] [blame] | 2104 | INF.info(FINISH_UP) |
Neal Norwitz | b4a2df0 | 2003-01-02 14:56:39 +0000 | [diff] [blame] | 2105 | |
Brett Cannon | f9db8a3 | 2008-02-17 01:59:18 +0000 | [diff] [blame] | 2106 | def test_main_inner(): |
| 2107 | rootLogger = logging.getLogger("") |
| 2108 | rootLogger.setLevel(logging.DEBUG) |
Neal Norwitz | b4a2df0 | 2003-01-02 14:56:39 +0000 | [diff] [blame] | 2109 | |
Georg Brandl | 57826cf | 2008-02-23 15:06:25 +0000 | [diff] [blame] | 2110 | tcpserver = LogRecordSocketReceiver(port=0) |
| 2111 | port = tcpserver.socket.getsockname()[1] |
Neal Norwitz | b4a2df0 | 2003-01-02 14:56:39 +0000 | [diff] [blame] | 2112 | |
Georg Brandl | 57826cf | 2008-02-23 15:06:25 +0000 | [diff] [blame] | 2113 | # Set up a handler such that all events are sent via a socket to the log |
| 2114 | # receiver (logrecv). |
| 2115 | # The handler will only be added to the rootLogger for some of the tests |
Brett Cannon | f9db8a3 | 2008-02-17 01:59:18 +0000 | [diff] [blame] | 2116 | shdlr = logging.handlers.SocketHandler('localhost', port) |
| 2117 | rootLogger.addHandler(shdlr) |
Neal Norwitz | b4a2df0 | 2003-01-02 14:56:39 +0000 | [diff] [blame] | 2118 | |
Georg Brandl | 57826cf | 2008-02-23 15:06:25 +0000 | [diff] [blame] | 2119 | # Configure the logger for logrecv so events do not propagate beyond it. |
| 2120 | # The sockLogger output is buffered in memory until the end of the test, |
| 2121 | # and printed at the end. |
Brett Cannon | f9db8a3 | 2008-02-17 01:59:18 +0000 | [diff] [blame] | 2122 | sockOut = cStringIO.StringIO() |
| 2123 | sockLogger = logging.getLogger("logrecv") |
| 2124 | sockLogger.setLevel(logging.DEBUG) |
| 2125 | sockhdlr = logging.StreamHandler(sockOut) |
| 2126 | sockhdlr.setFormatter(logging.Formatter( |
| 2127 | "%(name)s -> %(levelname)s: %(message)s")) |
| 2128 | sockLogger.addHandler(sockhdlr) |
| 2129 | sockLogger.propagate = 0 |
Neal Norwitz | b4a2df0 | 2003-01-02 14:56:39 +0000 | [diff] [blame] | 2130 | |
Brett Cannon | f9db8a3 | 2008-02-17 01:59:18 +0000 | [diff] [blame] | 2131 | #Set up servers |
| 2132 | threads = [] |
| 2133 | #sys.stdout.write("About to start TCP server...\n") |
| 2134 | threads.append(threading.Thread(target=runTCP, args=(tcpserver,))) |
Neal Norwitz | b4a2df0 | 2003-01-02 14:56:39 +0000 | [diff] [blame] | 2135 | |
Brett Cannon | f9db8a3 | 2008-02-17 01:59:18 +0000 | [diff] [blame] | 2136 | for thread in threads: |
| 2137 | thread.start() |
| 2138 | try: |
| 2139 | test0() |
Neal Norwitz | b4a2df0 | 2003-01-02 14:56:39 +0000 | [diff] [blame] | 2140 | |
Brett Cannon | f9db8a3 | 2008-02-17 01:59:18 +0000 | [diff] [blame] | 2141 | # XXX(nnorwitz): Try to fix timing related test failures. |
| 2142 | # This sleep gives us some extra time to read messages. |
| 2143 | # The test generally only fails on Solaris without this sleep. |
| 2144 | #time.sleep(2.0) |
| 2145 | shdlr.close() |
| 2146 | rootLogger.removeHandler(shdlr) |
Neal Norwitz | b4a2df0 | 2003-01-02 14:56:39 +0000 | [diff] [blame] | 2147 | |
Brett Cannon | f9db8a3 | 2008-02-17 01:59:18 +0000 | [diff] [blame] | 2148 | finally: |
| 2149 | #wait for TCP receiver to terminate |
Georg Brandl | 57826cf | 2008-02-23 15:06:25 +0000 | [diff] [blame] | 2150 | socketDataProcessed.wait() |
Brett Cannon | f9db8a3 | 2008-02-17 01:59:18 +0000 | [diff] [blame] | 2151 | # ensure the server dies |
Georg Brandl | 57826cf | 2008-02-23 15:06:25 +0000 | [diff] [blame] | 2152 | tcpserver.abort = True |
Brett Cannon | f9db8a3 | 2008-02-17 01:59:18 +0000 | [diff] [blame] | 2153 | for thread in threads: |
| 2154 | thread.join(2.0) |
| 2155 | print(sockOut.getvalue()) |
| 2156 | sockOut.close() |
| 2157 | sockLogger.removeHandler(sockhdlr) |
| 2158 | sockhdlr.close() |
| 2159 | sys.stdout.flush() |
Vinay Sajip | 22b25aa | 2006-01-16 21:24:38 +0000 | [diff] [blame] | 2160 | |
Vinay Sajip | 568482a | 2006-01-20 18:29:36 +0000 | [diff] [blame] | 2161 | # config0 is a standard configuration. |
Vinay Sajip | 22b25aa | 2006-01-16 21:24:38 +0000 | [diff] [blame] | 2162 | config0 = """ |
| 2163 | [loggers] |
| 2164 | keys=root |
| 2165 | |
| 2166 | [handlers] |
| 2167 | keys=hand1 |
| 2168 | |
| 2169 | [formatters] |
| 2170 | keys=form1 |
| 2171 | |
| 2172 | [logger_root] |
| 2173 | level=NOTSET |
| 2174 | handlers=hand1 |
| 2175 | |
| 2176 | [handler_hand1] |
| 2177 | class=StreamHandler |
| 2178 | level=NOTSET |
| 2179 | formatter=form1 |
| 2180 | args=(sys.stdout,) |
| 2181 | |
| 2182 | [formatter_form1] |
| 2183 | format=%(levelname)s:%(name)s:%(message)s |
| 2184 | datefmt= |
| 2185 | """ |
| 2186 | |
| 2187 | # config1 adds a little to the standard configuration. |
| 2188 | config1 = """ |
| 2189 | [loggers] |
| 2190 | keys=root,parser |
| 2191 | |
| 2192 | [handlers] |
| 2193 | keys=hand1 |
| 2194 | |
| 2195 | [formatters] |
| 2196 | keys=form1 |
| 2197 | |
| 2198 | [logger_root] |
| 2199 | level=NOTSET |
| 2200 | handlers=hand1 |
| 2201 | |
| 2202 | [logger_parser] |
| 2203 | level=DEBUG |
| 2204 | handlers=hand1 |
| 2205 | propagate=1 |
| 2206 | qualname=compiler.parser |
| 2207 | |
| 2208 | [handler_hand1] |
| 2209 | class=StreamHandler |
| 2210 | level=NOTSET |
| 2211 | formatter=form1 |
| 2212 | args=(sys.stdout,) |
| 2213 | |
| 2214 | [formatter_form1] |
| 2215 | format=%(levelname)s:%(name)s:%(message)s |
| 2216 | datefmt= |
| 2217 | """ |
| 2218 | |
Brett Cannon | f9db8a3 | 2008-02-17 01:59:18 +0000 | [diff] [blame] | 2219 | def message(s): |
| 2220 | sys.stdout.write("%s\n" % s) |
| 2221 | |
Vinay Sajip | 22b25aa | 2006-01-16 21:24:38 +0000 | [diff] [blame] | 2222 | # config2 has a subtle configuration error that should be reported |
| 2223 | config2 = string.replace(config1, "sys.stdout", "sys.stbout") |
| 2224 | |
| 2225 | # config3 has a less subtle configuration error |
| 2226 | config3 = string.replace( |
| 2227 | config1, "formatter=form1", "formatter=misspelled_name") |
| 2228 | |
Tim Peters | 36f7e93 | 2003-07-23 00:05:07 +0000 | [diff] [blame] | 2229 | def test_main(): |
Brett Cannon | f9db8a3 | 2008-02-17 01:59:18 +0000 | [diff] [blame] | 2230 | from test import test_support, test_logging |
| 2231 | test_support.run_doctest(test_logging) |
Jeremy Hylton | 096d986 | 2003-07-18 03:19:20 +0000 | [diff] [blame] | 2232 | |
Brett Cannon | f9db8a3 | 2008-02-17 01:59:18 +0000 | [diff] [blame] | 2233 | if __name__=="__main__": |
Neal Norwitz | b4a2df0 | 2003-01-02 14:56:39 +0000 | [diff] [blame] | 2234 | test_main() |