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
30e6a64e
Kaydet (Commit)
30e6a64e
authored
Ock 13, 2014
tarafından
Vinay Sajip
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Sade Fark
Closes #20242: Merged fix from 3.3.
üst
936dfae2
1fd12020
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
29 additions
and
7 deletions
+29
-7
__init__.py
Lib/logging/__init__.py
+10
-7
test_logging.py
Lib/test/test_logging.py
+16
-0
NEWS
Misc/NEWS
+3
-0
No files found.
Lib/logging/__init__.py
Dosyayı görüntüle @
30e6a64e
...
@@ -390,10 +390,12 @@ class StringTemplateStyle(PercentStyle):
...
@@ -390,10 +390,12 @@ class StringTemplateStyle(PercentStyle):
def
format
(
self
,
record
):
def
format
(
self
,
record
):
return
self
.
_tpl
.
substitute
(
**
record
.
__dict__
)
return
self
.
_tpl
.
substitute
(
**
record
.
__dict__
)
BASIC_FORMAT
=
"
%(levelname)
s:
%(name)
s:
%(message)
s"
_STYLES
=
{
_STYLES
=
{
'
%
'
:
PercentStyle
,
'
%
'
:
(
PercentStyle
,
BASIC_FORMAT
)
,
'{'
:
StrFormatStyle
,
'{'
:
(
StrFormatStyle
,
'{levelname}:{name}:{message}'
)
,
'$'
:
StringTemplateStyle
'$'
:
(
StringTemplateStyle
,
'${levelname}:${name}:${message}'
),
}
}
class
Formatter
(
object
):
class
Formatter
(
object
):
...
@@ -458,7 +460,7 @@ class Formatter(object):
...
@@ -458,7 +460,7 @@ class Formatter(object):
if
style
not
in
_STYLES
:
if
style
not
in
_STYLES
:
raise
ValueError
(
'Style must be one of:
%
s'
%
','
.
join
(
raise
ValueError
(
'Style must be one of:
%
s'
%
','
.
join
(
_STYLES
.
keys
()))
_STYLES
.
keys
()))
self
.
_style
=
_STYLES
[
style
](
fmt
)
self
.
_style
=
_STYLES
[
style
]
[
0
]
(
fmt
)
self
.
_fmt
=
self
.
_style
.
_fmt
self
.
_fmt
=
self
.
_style
.
_fmt
self
.
datefmt
=
datefmt
self
.
datefmt
=
datefmt
...
@@ -1643,8 +1645,6 @@ Logger.manager = Manager(Logger.root)
...
@@ -1643,8 +1645,6 @@ Logger.manager = Manager(Logger.root)
# Configuration classes and functions
# Configuration classes and functions
#---------------------------------------------------------------------------
#---------------------------------------------------------------------------
BASIC_FORMAT
=
"
%(levelname)
s:
%(name)
s:
%(message)
s"
def
basicConfig
(
**
kwargs
):
def
basicConfig
(
**
kwargs
):
"""
"""
Do basic configuration for the logging system.
Do basic configuration for the logging system.
...
@@ -1718,9 +1718,12 @@ def basicConfig(**kwargs):
...
@@ -1718,9 +1718,12 @@ def basicConfig(**kwargs):
stream
=
kwargs
.
get
(
"stream"
)
stream
=
kwargs
.
get
(
"stream"
)
h
=
StreamHandler
(
stream
)
h
=
StreamHandler
(
stream
)
handlers
=
[
h
]
handlers
=
[
h
]
fs
=
kwargs
.
get
(
"format"
,
BASIC_FORMAT
)
dfs
=
kwargs
.
get
(
"datefmt"
,
None
)
dfs
=
kwargs
.
get
(
"datefmt"
,
None
)
style
=
kwargs
.
get
(
"style"
,
'
%
'
)
style
=
kwargs
.
get
(
"style"
,
'
%
'
)
if
style
not
in
_STYLES
:
raise
ValueError
(
'Style must be one of:
%
s'
%
','
.
join
(
_STYLES
.
keys
()))
fs
=
kwargs
.
get
(
"format"
,
_STYLES
[
style
][
1
])
fmt
=
Formatter
(
fs
,
dfs
,
style
)
fmt
=
Formatter
(
fs
,
dfs
,
style
)
for
h
in
handlers
:
for
h
in
handlers
:
if
h
.
formatter
is
None
:
if
h
.
formatter
is
None
:
...
...
Lib/test/test_logging.py
Dosyayı görüntüle @
30e6a64e
...
@@ -3517,6 +3517,22 @@ class BasicConfigTest(unittest.TestCase):
...
@@ -3517,6 +3517,22 @@ class BasicConfigTest(unittest.TestCase):
# level is not explicitly set
# level is not explicitly set
self
.
assertEqual
(
logging
.
root
.
level
,
self
.
original_logging_level
)
self
.
assertEqual
(
logging
.
root
.
level
,
self
.
original_logging_level
)
def
test_strformatstyle
(
self
):
with
captured_stdout
()
as
output
:
logging
.
basicConfig
(
stream
=
sys
.
stdout
,
style
=
"{"
)
logging
.
error
(
"Log an error"
)
sys
.
stdout
.
seek
(
0
)
self
.
assertEqual
(
output
.
getvalue
()
.
strip
(),
"ERROR:root:Log an error"
)
def
test_stringtemplatestyle
(
self
):
with
captured_stdout
()
as
output
:
logging
.
basicConfig
(
stream
=
sys
.
stdout
,
style
=
"$"
)
logging
.
error
(
"Log an error"
)
sys
.
stdout
.
seek
(
0
)
self
.
assertEqual
(
output
.
getvalue
()
.
strip
(),
"ERROR:root:Log an error"
)
def
test_filename
(
self
):
def
test_filename
(
self
):
def
cleanup
(
h1
,
h2
,
fn
):
def
cleanup
(
h1
,
h2
,
fn
):
...
...
Misc/NEWS
Dosyayı görüntüle @
30e6a64e
...
@@ -25,6 +25,9 @@ Core and Builtins
...
@@ -25,6 +25,9 @@ Core and Builtins
Library
Library
-------
-------
- Issue #20242: Fixed basicConfig() format strings for the alternative
formatting styles. Thanks to kespindler for the bug report and patch.
- Issues #20206 and #5803: Fix edge case in email.quoprimime.encode where it
- Issues #20206 and #5803: Fix edge case in email.quoprimime.encode where it
truncated lines ending in a character needing encoding but no newline by
truncated lines ending in a character needing encoding but no newline by
using a more efficient algorithm that doesn'
t
have
the
bug
.
using a more efficient algorithm that doesn'
t
have
the
bug
.
...
...
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