Reverted bug fixes for #11444 (fc4d045e3170) and #11424 (b9d76846bb1c), which should not have been made in this branch.
This commit is contained in:
parent
f4d0af460a
commit
3ae81137c8
|
@ -1513,15 +1513,12 @@ def shutdown(handlerList=_handlerList):
|
||||||
#errors might occur, for example, if files are locked
|
#errors might occur, for example, if files are locked
|
||||||
#we just ignore them if raiseExceptions is not set
|
#we just ignore them if raiseExceptions is not set
|
||||||
try:
|
try:
|
||||||
h.acquire()
|
|
||||||
h.flush()
|
h.flush()
|
||||||
h.close()
|
h.close()
|
||||||
except:
|
except:
|
||||||
if raiseExceptions:
|
if raiseExceptions:
|
||||||
raise
|
raise
|
||||||
#else, swallow
|
#else, swallow
|
||||||
finally:
|
|
||||||
h.release()
|
|
||||||
|
|
||||||
#Let's try and shutdown automatically on application exit...
|
#Let's try and shutdown automatically on application exit...
|
||||||
try:
|
try:
|
||||||
|
|
|
@ -232,14 +232,14 @@ def _install_loggers(cp, handlers, disable_existing_loggers):
|
||||||
propagate = 1
|
propagate = 1
|
||||||
logger = logging.getLogger(qn)
|
logger = logging.getLogger(qn)
|
||||||
if qn in existing:
|
if qn in existing:
|
||||||
i = existing.index(qn) + 1 # start with the entry after qn
|
i = existing.index(qn)
|
||||||
prefixed = qn + "."
|
prefixed = qn + "."
|
||||||
pflen = len(prefixed)
|
pflen = len(prefixed)
|
||||||
num_existing = len(existing)
|
num_existing = len(existing)
|
||||||
while i < num_existing:
|
i = i + 1 # look at the entry after qn
|
||||||
if existing[i][:pflen] == prefixed:
|
while (i < num_existing) and (existing[i][:pflen] == prefixed):
|
||||||
child_loggers.append(existing[i])
|
child_loggers.append(existing[i])
|
||||||
i += 1
|
i = i + 1
|
||||||
existing.remove(qn)
|
existing.remove(qn)
|
||||||
if "level" in opts:
|
if "level" in opts:
|
||||||
level = cp.get(sectname, "level")
|
level = cp.get(sectname, "level")
|
||||||
|
|
|
@ -558,38 +558,6 @@ class ConfigFileTest(BaseTest):
|
||||||
datefmt=
|
datefmt=
|
||||||
"""
|
"""
|
||||||
|
|
||||||
# config1a moves the handler to the root.
|
|
||||||
config1a = """
|
|
||||||
[loggers]
|
|
||||||
keys=root,parser
|
|
||||||
|
|
||||||
[handlers]
|
|
||||||
keys=hand1
|
|
||||||
|
|
||||||
[formatters]
|
|
||||||
keys=form1
|
|
||||||
|
|
||||||
[logger_root]
|
|
||||||
level=WARNING
|
|
||||||
handlers=hand1
|
|
||||||
|
|
||||||
[logger_parser]
|
|
||||||
level=DEBUG
|
|
||||||
handlers=
|
|
||||||
propagate=1
|
|
||||||
qualname=compiler.parser
|
|
||||||
|
|
||||||
[handler_hand1]
|
|
||||||
class=StreamHandler
|
|
||||||
level=NOTSET
|
|
||||||
formatter=form1
|
|
||||||
args=(sys.stdout,)
|
|
||||||
|
|
||||||
[formatter_form1]
|
|
||||||
format=%(levelname)s ++ %(message)s
|
|
||||||
datefmt=
|
|
||||||
"""
|
|
||||||
|
|
||||||
# config2 has a subtle configuration error that should be reported
|
# config2 has a subtle configuration error that should be reported
|
||||||
config2 = config1.replace("sys.stdout", "sys.stbout")
|
config2 = config1.replace("sys.stdout", "sys.stbout")
|
||||||
|
|
||||||
|
@ -668,44 +636,6 @@ class ConfigFileTest(BaseTest):
|
||||||
datefmt=
|
datefmt=
|
||||||
"""
|
"""
|
||||||
|
|
||||||
# config7 adds a compiler logger.
|
|
||||||
config7 = """
|
|
||||||
[loggers]
|
|
||||||
keys=root,parser,compiler
|
|
||||||
|
|
||||||
[handlers]
|
|
||||||
keys=hand1
|
|
||||||
|
|
||||||
[formatters]
|
|
||||||
keys=form1
|
|
||||||
|
|
||||||
[logger_root]
|
|
||||||
level=WARNING
|
|
||||||
handlers=hand1
|
|
||||||
|
|
||||||
[logger_compiler]
|
|
||||||
level=DEBUG
|
|
||||||
handlers=
|
|
||||||
propagate=1
|
|
||||||
qualname=compiler
|
|
||||||
|
|
||||||
[logger_parser]
|
|
||||||
level=DEBUG
|
|
||||||
handlers=
|
|
||||||
propagate=1
|
|
||||||
qualname=compiler.parser
|
|
||||||
|
|
||||||
[handler_hand1]
|
|
||||||
class=StreamHandler
|
|
||||||
level=NOTSET
|
|
||||||
formatter=form1
|
|
||||||
args=(sys.stdout,)
|
|
||||||
|
|
||||||
[formatter_form1]
|
|
||||||
format=%(levelname)s ++ %(message)s
|
|
||||||
datefmt=
|
|
||||||
"""
|
|
||||||
|
|
||||||
def apply_config(self, conf):
|
def apply_config(self, conf):
|
||||||
try:
|
try:
|
||||||
fn = tempfile.mktemp(".ini")
|
fn = tempfile.mktemp(".ini")
|
||||||
|
@ -775,49 +705,6 @@ class ConfigFileTest(BaseTest):
|
||||||
def test_config6_ok(self):
|
def test_config6_ok(self):
|
||||||
self.test_config1_ok(config=self.config6)
|
self.test_config1_ok(config=self.config6)
|
||||||
|
|
||||||
def test_config7_ok(self):
|
|
||||||
with captured_stdout() as output:
|
|
||||||
self.apply_config(self.config1a)
|
|
||||||
logger = logging.getLogger("compiler.parser")
|
|
||||||
# See issue #11424. compiler-hyphenated sorts
|
|
||||||
# between compiler and compiler.xyz and this
|
|
||||||
# was preventing compiler.xyz from being included
|
|
||||||
# in the child loggers of compiler because of an
|
|
||||||
# overzealous loop termination condition.
|
|
||||||
hyphenated = logging.getLogger('compiler-hyphenated')
|
|
||||||
# All will output a message
|
|
||||||
logger.info(self.next_message())
|
|
||||||
logger.error(self.next_message())
|
|
||||||
hyphenated.critical(self.next_message())
|
|
||||||
self.assert_log_lines([
|
|
||||||
('INFO', '1'),
|
|
||||||
('ERROR', '2'),
|
|
||||||
('CRITICAL', '3'),
|
|
||||||
], stream=output)
|
|
||||||
# Original logger output is empty.
|
|
||||||
self.assert_log_lines([])
|
|
||||||
with captured_stdout() as output:
|
|
||||||
self.apply_config(self.config7)
|
|
||||||
logger = logging.getLogger("compiler.parser")
|
|
||||||
self.assertFalse(logger.disabled)
|
|
||||||
# Both will output a message
|
|
||||||
logger.info(self.next_message())
|
|
||||||
logger.error(self.next_message())
|
|
||||||
logger = logging.getLogger("compiler.lexer")
|
|
||||||
# Both will output a message
|
|
||||||
logger.info(self.next_message())
|
|
||||||
logger.error(self.next_message())
|
|
||||||
# Will not appear
|
|
||||||
hyphenated.critical(self.next_message())
|
|
||||||
self.assert_log_lines([
|
|
||||||
('INFO', '4'),
|
|
||||||
('ERROR', '5'),
|
|
||||||
('INFO', '6'),
|
|
||||||
('ERROR', '7'),
|
|
||||||
], stream=output)
|
|
||||||
# Original logger output is empty.
|
|
||||||
self.assert_log_lines([])
|
|
||||||
|
|
||||||
class LogRecordStreamHandler(StreamRequestHandler):
|
class LogRecordStreamHandler(StreamRequestHandler):
|
||||||
|
|
||||||
"""Handler for a streaming logging request. It saves the log message in the
|
"""Handler for a streaming logging request. It saves the log message in the
|
||||||
|
|
Loading…
Reference in New Issue