debuggers.hg

view tools/python/logging/logging-0.4.9.2/test/log_test6.py @ 0:7d21f7218375

Exact replica of unstable on 051908 + README-this
author Mukesh Rathor
date Mon May 19 15:34:57 2008 -0700 (2008-05-19)
parents
children dae98734f12e
line source
1 #!/usr/bin/env python
2 #
3 # Copyright 2001-2002 by Vinay Sajip. All Rights Reserved.
4 #
5 # Permission to use, copy, modify, and distribute this software and its
6 # documentation for any purpose and without fee is hereby granted,
7 # provided that the above copyright notice appear in all copies and that
8 # both that copyright notice and this permission notice appear in
9 # supporting documentation, and that the name of Vinay Sajip
10 # not be used in advertising or publicity pertaining to distribution
11 # of the software without specific, written prior permission.
12 # VINAY SAJIP DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
13 # ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL
14 # VINAY SAJIP BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
15 # ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER
16 # IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT
17 # OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
18 #
19 # This file is part of the Python logging distribution. See
20 # http://www.red-dove.com/python_logging.html
21 #
22 """
23 A test harness for the logging module. Tests NTEventLogHandler.
25 Copyright (C) 2001-2002 Vinay Sajip. All Rights Reserved.
26 """
27 import logging, logging.handlers
29 def main():
30 ntl = logging.handlers.NTEventLogHandler("Python Logging Test")
31 logger = logging.getLogger("")
32 logger.setLevel(logging.DEBUG)
33 logger.addHandler(ntl)
34 logger.debug("This is a '%s' message", "Debug")
35 logger.info("This is a '%s' message", "Info")
36 logger.warning("This is a '%s' message", "Warning")
37 logger.error("This is a '%s' message", "Error")
38 logger.critical("This is a '%s' message", "Critical")
39 try:
40 x = 4 / 0
41 except:
42 logger.info("This is an %s (or should that be %s?)", "informational exception", "exceptional information", exc_info=1)
43 logger.exception("This is the same stuff, via a %s", "exception() call")
44 logger.removeHandler(ntl)
46 if __name__ == "__main__":
47 main()