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
6a2fd813
Kaydet (Commit)
6a2fd813
authored
Eyl 03, 2008
tarafından
Vinay Sajip
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Issue #3726: Allowed spaces in separators in logging configuration files.
üst
ff7b2d5a
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
58 additions
and
5 deletions
+58
-5
config.py
Lib/logging/config.py
+11
-5
test_logging.py
Lib/test/test_logging.py
+45
-0
NEWS
Misc/NEWS
+2
-0
No files found.
Lib/logging/config.py
Dosyayı görüntüle @
6a2fd813
...
@@ -22,7 +22,7 @@ by Apache's log4j system.
...
@@ -22,7 +22,7 @@ by Apache's log4j system.
Should work under Python versions >= 1.5.2, except that source line
Should work under Python versions >= 1.5.2, except that source line
information is not available unless 'sys._getframe()' is.
information is not available unless 'sys._getframe()' is.
Copyright (C) 2001-200
7
Vinay Sajip. All Rights Reserved.
Copyright (C) 2001-200
8
Vinay Sajip. All Rights Reserved.
To use, simply 'import logging' and log away!
To use, simply 'import logging' and log away!
"""
"""
...
@@ -101,6 +101,8 @@ def _resolve(name):
...
@@ -101,6 +101,8 @@ def _resolve(name):
found
=
getattr
(
found
,
n
)
found
=
getattr
(
found
,
n
)
return
found
return
found
def
_strip_spaces
(
alist
):
return
map
(
lambda
x
:
string
.
strip
(
x
),
alist
)
def
_create_formatters
(
cp
):
def
_create_formatters
(
cp
):
"""Create and return formatters"""
"""Create and return formatters"""
...
@@ -108,9 +110,10 @@ def _create_formatters(cp):
...
@@ -108,9 +110,10 @@ def _create_formatters(cp):
if
not
len
(
flist
):
if
not
len
(
flist
):
return
{}
return
{}
flist
=
string
.
split
(
flist
,
","
)
flist
=
string
.
split
(
flist
,
","
)
flist
=
_strip_spaces
(
flist
)
formatters
=
{}
formatters
=
{}
for
form
in
flist
:
for
form
in
flist
:
sectname
=
"formatter_
%
s"
%
string
.
strip
(
form
)
sectname
=
"formatter_
%
s"
%
form
opts
=
cp
.
options
(
sectname
)
opts
=
cp
.
options
(
sectname
)
if
"format"
in
opts
:
if
"format"
in
opts
:
fs
=
cp
.
get
(
sectname
,
"format"
,
1
)
fs
=
cp
.
get
(
sectname
,
"format"
,
1
)
...
@@ -136,10 +139,11 @@ def _install_handlers(cp, formatters):
...
@@ -136,10 +139,11 @@ def _install_handlers(cp, formatters):
if
not
len
(
hlist
):
if
not
len
(
hlist
):
return
{}
return
{}
hlist
=
string
.
split
(
hlist
,
","
)
hlist
=
string
.
split
(
hlist
,
","
)
hlist
=
_strip_spaces
(
hlist
)
handlers
=
{}
handlers
=
{}
fixups
=
[]
#for inter-handler references
fixups
=
[]
#for inter-handler references
for
hand
in
hlist
:
for
hand
in
hlist
:
sectname
=
"handler_
%
s"
%
string
.
strip
(
hand
)
sectname
=
"handler_
%
s"
%
hand
klass
=
cp
.
get
(
sectname
,
"class"
)
klass
=
cp
.
get
(
sectname
,
"class"
)
opts
=
cp
.
options
(
sectname
)
opts
=
cp
.
options
(
sectname
)
if
"formatter"
in
opts
:
if
"formatter"
in
opts
:
...
@@ -192,8 +196,9 @@ def _install_loggers(cp, handlers, disable_existing_loggers):
...
@@ -192,8 +196,9 @@ def _install_loggers(cp, handlers, disable_existing_loggers):
hlist
=
cp
.
get
(
sectname
,
"handlers"
)
hlist
=
cp
.
get
(
sectname
,
"handlers"
)
if
len
(
hlist
):
if
len
(
hlist
):
hlist
=
string
.
split
(
hlist
,
","
)
hlist
=
string
.
split
(
hlist
,
","
)
hlist
=
_strip_spaces
(
hlist
)
for
hand
in
hlist
:
for
hand
in
hlist
:
log
.
addHandler
(
handlers
[
string
.
strip
(
hand
)
])
log
.
addHandler
(
handlers
[
hand
])
#and now the others...
#and now the others...
#we don't want to lose the existing loggers,
#we don't want to lose the existing loggers,
...
@@ -243,8 +248,9 @@ def _install_loggers(cp, handlers, disable_existing_loggers):
...
@@ -243,8 +248,9 @@ def _install_loggers(cp, handlers, disable_existing_loggers):
hlist
=
cp
.
get
(
sectname
,
"handlers"
)
hlist
=
cp
.
get
(
sectname
,
"handlers"
)
if
len
(
hlist
):
if
len
(
hlist
):
hlist
=
string
.
split
(
hlist
,
","
)
hlist
=
string
.
split
(
hlist
,
","
)
hlist
=
_strip_spaces
(
hlist
)
for
hand
in
hlist
:
for
hand
in
hlist
:
logger
.
addHandler
(
handlers
[
string
.
strip
(
hand
)
])
logger
.
addHandler
(
handlers
[
hand
])
#Disable any old loggers. There's no point deleting
#Disable any old loggers. There's no point deleting
#them as other threads may continue to hold references
#them as other threads may continue to hold references
...
...
Lib/test/test_logging.py
Dosyayı görüntüle @
6a2fd813
...
@@ -587,6 +587,48 @@ class ConfigFileTest(BaseTest):
...
@@ -587,6 +587,48 @@ class ConfigFileTest(BaseTest):
# config5 specifies a custom handler class to be loaded
# config5 specifies a custom handler class to be loaded
config5
=
config1
.
replace
(
'class=StreamHandler'
,
'class=logging.StreamHandler'
)
config5
=
config1
.
replace
(
'class=StreamHandler'
,
'class=logging.StreamHandler'
)
# config6 uses ', ' delimiters in the handlers and formatters sections
config6
=
"""
[loggers]
keys=root,parser
[handlers]
keys=hand1, hand2
[formatters]
keys=form1, form2
[logger_root]
level=WARNING
handlers=
[logger_parser]
level=DEBUG
handlers=hand1
propagate=1
qualname=compiler.parser
[handler_hand1]
class=StreamHandler
level=NOTSET
formatter=form1
args=(sys.stdout,)
[handler_hand2]
class=FileHandler
level=NOTSET
formatter=form1
args=('test.blah', 'a')
[formatter_form1]
format=
%(levelname)
s ++
%(message)
s
datefmt=
[formatter_form2]
format=
%(message)
s
datefmt=
"""
def
apply_config
(
self
,
conf
):
def
apply_config
(
self
,
conf
):
try
:
try
:
fn
=
tempfile
.
mktemp
(
".ini"
)
fn
=
tempfile
.
mktemp
(
".ini"
)
...
@@ -653,6 +695,9 @@ class ConfigFileTest(BaseTest):
...
@@ -653,6 +695,9 @@ class ConfigFileTest(BaseTest):
def
test_config5_ok
(
self
):
def
test_config5_ok
(
self
):
self
.
test_config1_ok
(
config
=
self
.
config5
)
self
.
test_config1_ok
(
config
=
self
.
config5
)
def
test_config6_ok
(
self
):
self
.
test_config1_ok
(
config
=
self
.
config6
)
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
...
...
Misc/NEWS
Dosyayı görüntüle @
6a2fd813
...
@@ -56,6 +56,8 @@ C-API
...
@@ -56,6 +56,8 @@ C-API
Library
Library
-------
-------
- Issue #3726: Allowed spaces in separators in logging configuration files.
- Issue #3719: platform.architecture() fails if there are spaces in the
- Issue #3719: platform.architecture() fails if there are spaces in the
path to the Python binary.
path to the Python binary.
...
...
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