Skip to content
Projeler
Gruplar
Parçacıklar
Yardım
Yükleniyor...
Oturum aç / Kaydol
Gezinmeyi değiştir
C
cpython
Proje
Proje
Ayrıntılar
Etkinlik
Cycle Analytics
Depo (repository)
Depo (repository)
Dosyalar
Kayıtlar (commit)
Dallar (branch)
Etiketler
Katkıda bulunanlar
Grafik
Karşılaştır
Grafikler
Konular (issue)
0
Konular (issue)
0
Liste
Pano
Etiketler
Kilometre Taşları
Birleştirme (merge) Talepleri
0
Birleştirme (merge) Talepleri
0
CI / CD
CI / CD
İş akışları (pipeline)
İşler
Zamanlamalar
Grafikler
Paketler
Paketler
Wiki
Wiki
Parçacıklar
Parçacıklar
Üyeler
Üyeler
Collapse sidebar
Close sidebar
Etkinlik
Grafik
Grafikler
Yeni bir konu (issue) oluştur
İşler
Kayıtlar (commit)
Konu (issue) Panoları
Kenar çubuğunu aç
Batuhan Osman TASKAYA
cpython
Commits
e783553d
Kaydet (Commit)
e783553d
authored
Mar 07, 2011
tarafından
Vinay Sajip
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Sade Fark
#Issue 11424: merged fix from 3.1.
üst
2ae5cffb
3f84b078
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
118 additions
and
5 deletions
+118
-5
config.py
Lib/logging/config.py
+5
-5
test_logging.py
Lib/test/test_logging.py
+113
-0
No files found.
Lib/logging/config.py
Dosyayı görüntüle @
e783553d
...
...
@@ -226,14 +226,14 @@ def _install_loggers(cp, handlers, disable_existing):
propagate
=
section
.
getint
(
"propagate"
,
fallback
=
1
)
logger
=
logging
.
getLogger
(
qn
)
if
qn
in
existing
:
i
=
existing
.
index
(
qn
)
i
=
existing
.
index
(
qn
)
+
1
# start with the entry after qn
prefixed
=
qn
+
"."
pflen
=
len
(
prefixed
)
num_existing
=
len
(
existing
)
i
=
i
+
1
# look at the entry after qn
while
(
i
<
num_existing
)
and
(
existing
[
i
][:
pflen
]
==
prefixed
)
:
child_loggers
.
append
(
existing
[
i
])
i
=
i
+
1
while
i
<
num_existing
:
if
existing
[
i
][:
pflen
]
==
prefixed
:
child_loggers
.
append
(
existing
[
i
])
i
+=
1
existing
.
remove
(
qn
)
if
"level"
in
section
:
level
=
section
[
"level"
]
...
...
Lib/test/test_logging.py
Dosyayı görüntüle @
e783553d
...
...
@@ -611,6 +611,38 @@ class ConfigFileTest(BaseTest):
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
=
config1
.
replace
(
"sys.stdout"
,
"sys.stbout"
)
...
...
@@ -689,6 +721,44 @@ class ConfigFileTest(BaseTest):
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
):
file
=
io
.
StringIO
(
textwrap
.
dedent
(
conf
))
logging
.
config
.
fileConfig
(
file
)
...
...
@@ -752,6 +822,49 @@ class ConfigFileTest(BaseTest):
def
test_config6_ok
(
self
):
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
):
"""Handler for a streaming logging request. It saves the log message in the
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment