Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(12653)

Side by Side Diff: Lib/logging/config.py

Issue 16110: Provide logging.config.configParserConfig
Patch Set: Created 6 years, 4 months ago
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 # Copyright 2001-2010 by Vinay Sajip. All Rights Reserved. 1 # Copyright 2001-2010 by Vinay Sajip. All Rights Reserved.
2 # 2 #
3 # Permission to use, copy, modify, and distribute this software and its 3 # Permission to use, copy, modify, and distribute this software and its
4 # documentation for any purpose and without fee is hereby granted, 4 # documentation for any purpose and without fee is hereby granted,
5 # provided that the above copyright notice appear in all copies and that 5 # provided that the above copyright notice appear in all copies and that
6 # both that copyright notice and this permission notice appear in 6 # both that copyright notice and this permission notice appear in
7 # supporting documentation, and that the name of Vinay Sajip 7 # supporting documentation, and that the name of Vinay Sajip
8 # not be used in advertising or publicity pertaining to distribution 8 # not be used in advertising or publicity pertaining to distribution
9 # of the software without specific, written prior permission. 9 # of the software without specific, written prior permission.
10 # VINAY SAJIP DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING 10 # VINAY SAJIP DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
59 developer provides a mechanism to present the choices and load the chosen 59 developer provides a mechanism to present the choices and load the chosen
60 configuration). 60 configuration).
61 """ 61 """
62 import configparser 62 import configparser
63 63
64 cp = configparser.ConfigParser(defaults) 64 cp = configparser.ConfigParser(defaults)
65 if hasattr(fname, 'readline'): 65 if hasattr(fname, 'readline'):
66 cp.read_file(fname) 66 cp.read_file(fname)
67 else: 67 else:
68 cp.read(fname) 68 cp.read(fname)
69
70 configParserConfig(cp, disable_existing_loggers=disable_existing_loggers):
71
72 def configParserConfig(cparser, disable_existing_loggers=True):
73 """
74 Configure logging as provided in a configparser.ConfigParser instance.
75 """
69 76
70 formatters = _create_formatters(cp) 77 formatters = _create_formatters(cp)
71 78
72 # critical section 79 # critical section
73 logging._acquireLock() 80 logging._acquireLock()
74 try: 81 try:
75 logging._handlers.clear() 82 logging._handlers.clear()
76 del logging._handlerList[:] 83 del logging._handlerList[:]
77 # Handlers add themselves to logging._handlers 84 # Handlers add themselves to logging._handlers
78 handlers = _install_handlers(cp, formatters) 85 handlers = _install_handlers(cp, formatters)
(...skipping 814 matching lines...) Expand 10 before | Expand all | Expand 10 after
893 Stop the listening server which was created with a call to listen(). 900 Stop the listening server which was created with a call to listen().
894 """ 901 """
895 global _listener 902 global _listener
896 logging._acquireLock() 903 logging._acquireLock()
897 try: 904 try:
898 if _listener: 905 if _listener:
899 _listener.abort = 1 906 _listener.abort = 1
900 _listener = None 907 _listener = None
901 finally: 908 finally:
902 logging._releaseLock() 909 logging._releaseLock()
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

RSS Feeds Recent Issues | This issue
This is Rietveld 894c83f36cb7+