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 | """Test harness for the logging module. A basic test of parents. |
---|
23 | |
---|
24 | Copyright (C) 2001-2002 Vinay Sajip. All Rights Reserved. |
---|
25 | """ |
---|
26 | |
---|
27 | import logging |
---|
28 | |
---|
29 | def main(): |
---|
30 | logging.basicConfig() |
---|
31 | root = logging.getLogger("") |
---|
32 | ab = logging.getLogger("a.b") |
---|
33 | abc = logging.getLogger("a.b.c") |
---|
34 | root.setLevel(logging.ERROR) |
---|
35 | ab.setLevel(logging.INFO) |
---|
36 | abc.info("Info") |
---|
37 | abc.warning("Warning") |
---|
38 | abc.error("Error") |
---|
39 | print "abc = %s" % abc |
---|
40 | print "abc.parent = %s" % abc.parent |
---|
41 | print "ab = %s" % ab |
---|
42 | print "ab.parent = %s" % ab.parent |
---|
43 | print "root = %s" % root |
---|
44 | |
---|
45 | if __name__ == "__main__": |
---|
46 | import sys |
---|
47 | print sys.argv[0] |
---|
48 | args = sys.argv[1:] |
---|
49 | if "-profile" in args: |
---|
50 | import profile, pstats |
---|
51 | args.remove("-profile") |
---|
52 | statf = "log_test19.pro" |
---|
53 | profile.run("main()", statf) |
---|
54 | stats = pstats.Stats(statf) |
---|
55 | stats.strip_dirs().sort_stats('time').print_stats() |
---|
56 | else: |
---|
57 | main() |
---|