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
01500016
Unverified
Kaydet (Commit)
01500016
authored
Haz 19, 2019
tarafından
Vinay Sajip
Kaydeden (comit)
GitHub
Haz 19, 2019
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
bpo-37258: Not a bug, but added a unit test and updated documentation. (GH-14229)
üst
987a0dcf
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
36 additions
and
3 deletions
+36
-3
logging.rst
Doc/library/logging.rst
+5
-3
test_logging.py
Lib/test/test_logging.py
+31
-0
No files found.
Doc/library/logging.rst
Dosyayı görüntüle @
01500016
...
@@ -50,8 +50,8 @@ listed below.
...
@@ -50,8 +50,8 @@ listed below.
Logger
Objects
Logger
Objects
--------------
--------------
Loggers
have
the
following
attributes
and
methods
.
Note
that
Loggers
are
never
Loggers
have
the
following
attributes
and
methods
.
Note
that
Loggers
should
instantiated
directly
,
but
always
through
the
module
-
level
function
*
NEVER
*
be
instantiated
directly
,
but
always
through
the
module
-
level
function
``
logging
.
getLogger
(
name
)``.
Multiple
calls
to
:
func
:`
getLogger
`
with
the
same
``
logging
.
getLogger
(
name
)``.
Multiple
calls
to
:
func
:`
getLogger
`
with
the
same
name
will
always
return
a
reference
to
the
same
Logger
object
.
name
will
always
return
a
reference
to
the
same
Logger
object
.
...
@@ -1244,7 +1244,9 @@ functions.
...
@@ -1244,7 +1244,9 @@ functions.
The
class
should
define
:
meth
:`
__init__
`
such
that
only
a
name
argument
is
The
class
should
define
:
meth
:`
__init__
`
such
that
only
a
name
argument
is
required
,
and
the
:
meth
:`
__init__
`
should
call
:
meth
:`
Logger
.
__init__
`.
This
required
,
and
the
:
meth
:`
__init__
`
should
call
:
meth
:`
Logger
.
__init__
`.
This
function
is
typically
called
before
any
loggers
are
instantiated
by
applications
function
is
typically
called
before
any
loggers
are
instantiated
by
applications
which
need
to
use
custom
logger
behavior
.
which
need
to
use
custom
logger
behavior
.
After
this
call
,
as
at
any
other
time
,
do
not
instantiate
loggers
directly
using
the
subclass
:
continue
to
use
the
:
func
:`
logging
.
getLogger
`
API
to
get
your
loggers
.
..
function
::
setLogRecordFactory
(
factory
)
..
function
::
setLogRecordFactory
(
factory
)
...
...
Lib/test/test_logging.py
Dosyayı görüntüle @
01500016
...
@@ -4172,6 +4172,37 @@ class ModuleLevelMiscTest(BaseTest):
...
@@ -4172,6 +4172,37 @@ class ModuleLevelMiscTest(BaseTest):
logging
.
setLoggerClass
(
logging
.
Logger
)
logging
.
setLoggerClass
(
logging
.
Logger
)
self
.
assertEqual
(
logging
.
getLoggerClass
(),
logging
.
Logger
)
self
.
assertEqual
(
logging
.
getLoggerClass
(),
logging
.
Logger
)
def
test_subclass_logger_cache
(
self
):
# bpo-37258
message
=
[]
class
MyLogger
(
logging
.
getLoggerClass
()):
def
__init__
(
self
,
name
=
'MyLogger'
,
level
=
logging
.
NOTSET
):
super
()
.
__init__
(
name
,
level
)
message
.
append
(
'initialized'
)
logging
.
setLoggerClass
(
MyLogger
)
logger
=
logging
.
getLogger
(
'just_some_logger'
)
self
.
assertEqual
(
message
,
[
'initialized'
])
stream
=
io
.
StringIO
()
h
=
logging
.
StreamHandler
(
stream
)
logger
.
addHandler
(
h
)
try
:
logger
.
setLevel
(
logging
.
DEBUG
)
logger
.
debug
(
"hello"
)
self
.
assertEqual
(
stream
.
getvalue
()
.
strip
(),
"hello"
)
stream
.
truncate
(
0
)
stream
.
seek
(
0
)
logger
.
setLevel
(
logging
.
INFO
)
logger
.
debug
(
"hello"
)
self
.
assertEqual
(
stream
.
getvalue
(),
""
)
finally
:
logger
.
removeHandler
(
h
)
h
.
close
()
logging
.
setLoggerClass
(
logging
.
Logger
)
@support.requires_type_collecting
@support.requires_type_collecting
def
test_logging_at_shutdown
(
self
):
def
test_logging_at_shutdown
(
self
):
# Issue #20037
# Issue #20037
...
...
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