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
8d27023a
Kaydet (Commit)
8d27023a
authored
Kas 15, 2012
tarafından
Vinay Sajip
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Allow configuration of handler properties.
üst
8f2b6ad9
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
39 additions
and
0 deletions
+39
-0
config.py
Lib/logging/config.py
+4
-0
test_logging.py
Lib/test/test_logging.py
+35
-0
No files found.
Lib/logging/config.py
Dosyayı görüntüle @
8d27023a
...
@@ -710,6 +710,7 @@ class DictConfigurator(BaseConfigurator):
...
@@ -710,6 +710,7 @@ class DictConfigurator(BaseConfigurator):
'address'
in
config
:
'address'
in
config
:
config
[
'address'
]
=
self
.
as_tuple
(
config
[
'address'
])
config
[
'address'
]
=
self
.
as_tuple
(
config
[
'address'
])
factory
=
klass
factory
=
klass
props
=
config
.
pop
(
'.'
,
None
)
kwargs
=
dict
([(
k
,
config
[
k
])
for
k
in
config
if
valid_ident
(
k
)])
kwargs
=
dict
([(
k
,
config
[
k
])
for
k
in
config
if
valid_ident
(
k
)])
try
:
try
:
result
=
factory
(
**
kwargs
)
result
=
factory
(
**
kwargs
)
...
@@ -728,6 +729,9 @@ class DictConfigurator(BaseConfigurator):
...
@@ -728,6 +729,9 @@ class DictConfigurator(BaseConfigurator):
result
.
setLevel
(
logging
.
_checkLevel
(
level
))
result
.
setLevel
(
logging
.
_checkLevel
(
level
))
if
filters
:
if
filters
:
self
.
add_filters
(
result
,
filters
)
self
.
add_filters
(
result
,
filters
)
if
props
:
for
name
,
value
in
props
.
items
():
setattr
(
result
,
name
,
value
)
return
result
return
result
def
add_handlers
(
self
,
logger
,
handlers
):
def
add_handlers
(
self
,
logger
,
handlers
):
...
...
Lib/test/test_logging.py
Dosyayı görüntüle @
8d27023a
...
@@ -2389,6 +2389,32 @@ class ConfigDictTest(BaseTest):
...
@@ -2389,6 +2389,32 @@ class ConfigDictTest(BaseTest):
},
},
}
}
# As config0, but with properties
config14
=
{
'version'
:
1
,
'formatters'
:
{
'form1'
:
{
'format'
:
'
%(levelname)
s ++
%(message)
s'
,
},
},
'handlers'
:
{
'hand1'
:
{
'class'
:
'logging.StreamHandler'
,
'formatter'
:
'form1'
,
'level'
:
'NOTSET'
,
'stream'
:
'ext://sys.stdout'
,
'.'
:
{
'foo'
:
'bar'
,
'terminator'
:
'!
\n
'
,
}
},
},
'root'
:
{
'level'
:
'WARNING'
,
'handlers'
:
[
'hand1'
],
},
}
def
apply_config
(
self
,
conf
):
def
apply_config
(
self
,
conf
):
logging
.
config
.
dictConfig
(
conf
)
logging
.
config
.
dictConfig
(
conf
)
...
@@ -2625,6 +2651,15 @@ class ConfigDictTest(BaseTest):
...
@@ -2625,6 +2651,15 @@ class ConfigDictTest(BaseTest):
def
test_config13_failure
(
self
):
def
test_config13_failure
(
self
):
self
.
assertRaises
(
Exception
,
self
.
apply_config
,
self
.
config13
)
self
.
assertRaises
(
Exception
,
self
.
apply_config
,
self
.
config13
)
def
test_config14_ok
(
self
):
with
captured_stdout
()
as
output
:
self
.
apply_config
(
self
.
config14
)
h
=
logging
.
_handlers
[
'hand1'
]
self
.
assertEqual
(
h
.
foo
,
'bar'
)
self
.
assertEqual
(
h
.
terminator
,
'!
\n
'
)
logging
.
warning
(
'Exclamation'
)
self
.
assertTrue
(
output
.
getvalue
()
.
endswith
(
'Exclamation!
\n
'
))
@unittest.skipUnless
(
threading
,
'listen() needs threading to work'
)
@unittest.skipUnless
(
threading
,
'listen() needs threading to work'
)
def
setup_via_listener
(
self
,
text
,
verify
=
None
):
def
setup_via_listener
(
self
,
text
,
verify
=
None
):
text
=
text
.
encode
(
"utf-8"
)
text
=
text
.
encode
(
"utf-8"
)
...
...
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