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
b4a0809a
Kaydet (Commit)
b4a0809a
authored
Eyl 20, 2010
tarafından
Vinay Sajip
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
logging: Add hasHandlers() method to Logger.
üst
f1d633c3
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
28 additions
and
5 deletions
+28
-5
__init__.py
Lib/logging/__init__.py
+22
-0
test_logging.py
Lib/test/test_logging.py
+6
-5
No files found.
Lib/logging/__init__.py
Dosyayı görüntüle @
b4a0809a
...
...
@@ -1240,6 +1240,28 @@ class Logger(Filterer):
finally
:
hdlr
.
release
()
def
hasHandlers
(
self
):
"""
See if this logger has any handlers configured.
Loop through all handlers for this logger and its parents in the
logger hierarchy. Return True if a handler was found, else False.
Stop searching up the hierarchy whenever a logger with the "propagate"
attribute set to zero is found - that will be the last logger which
is checked for the existence of handlers.
"""
c
=
self
rv
=
False
while
c
:
if
c
.
handlers
:
rv
=
True
break
if
not
c
.
propagate
:
break
else
:
c
=
c
.
parent
return
rv
def
callHandlers
(
self
,
record
):
"""
Pass a record to all relevant handlers.
...
...
Lib/test/test_logging.py
Dosyayı görüntüle @
b4a0809a
...
...
@@ -75,8 +75,8 @@ class BaseTest(unittest.TestCase):
# Set two unused loggers: one non-ASCII and one Unicode.
# This is to test correct operation when sorting existing
# loggers in the configuration code. See issue 8201.
logging
.
getLogger
(
"
\xab\xd7\xbb
"
)
logging
.
getLogger
(
"
\u013f\u00d6\u0047
"
)
self
.
logger1
=
logging
.
getLogger
(
"
\xab\xd7\xbb
"
)
self
.
logger2
=
logging
.
getLogger
(
"
\u013f\u00d6\u0047
"
)
self
.
root_logger
=
logging
.
getLogger
(
""
)
self
.
original_logging_level
=
self
.
root_logger
.
getEffectiveLevel
()
...
...
@@ -86,7 +86,11 @@ class BaseTest(unittest.TestCase):
self
.
root_hdlr
=
logging
.
StreamHandler
(
self
.
stream
)
self
.
root_formatter
=
logging
.
Formatter
(
self
.
log_format
)
self
.
root_hdlr
.
setFormatter
(
self
.
root_formatter
)
self
.
assertFalse
(
self
.
logger1
.
hasHandlers
())
self
.
assertFalse
(
self
.
logger2
.
hasHandlers
())
self
.
root_logger
.
addHandler
(
self
.
root_hdlr
)
self
.
assertTrue
(
self
.
logger1
.
hasHandlers
())
self
.
assertTrue
(
self
.
logger2
.
hasHandlers
())
def
tearDown
(
self
):
"""Remove our logging stream, and restore the original logging
...
...
@@ -1844,7 +1848,6 @@ class RotatingFileHandlerTest(BaseFileTest):
self
.
assertLogFile
(
self
.
fn
+
".2"
)
self
.
assertFalse
(
os
.
path
.
exists
(
self
.
fn
+
".3"
))
class
TimedRotatingFileHandlerTest
(
BaseFileTest
):
# test methods added below
pass
...
...
@@ -1865,8 +1868,6 @@ for when, exp in (('S', 1),
self
.
assertEquals
(
exp
,
rh
.
computeRollover
(
0.0
))
setattr
(
TimedRotatingFileHandlerTest
,
"test_compute_rollover_
%
s"
%
when
,
test_compute_rollover
)
# Set the locale to the platform-dependent default. I have no idea
# why the test does this, but in any case we save the current locale
# first and restore it at the end.
...
...
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