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
657514a6
Kaydet (Commit)
657514a6
authored
Şub 07, 2010
tarafından
Vinay Sajip
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Issue #7868: logging: added loggerClass attribute to Manager.
üst
12cad204
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
40 additions
and
10 deletions
+40
-10
__init__.py
Lib/logging/__init__.py
+16
-5
test_logging.py
Lib/test/test_logging.py
+22
-5
NEWS
Misc/NEWS
+2
-0
No files found.
Lib/logging/__init__.py
Dosyayı görüntüle @
657514a6
# Copyright 2001-20
09
by Vinay Sajip. All Rights Reserved.
# Copyright 2001-20
10
by Vinay Sajip. All Rights Reserved.
#
# Permission to use, copy, modify, and distribute this software and its
# documentation for any purpose and without fee is hereby granted,
...
...
@@ -46,8 +46,8 @@ except ImportError:
__author__
=
"Vinay Sajip <vinay_sajip@red-dove.com>"
__status__
=
"production"
__version__
=
"0.5.1.
1
"
__date__
=
"
25 November 2009
"
__version__
=
"0.5.1.
2
"
__date__
=
"
07 February 2010
"
#---------------------------------------------------------------------------
# Miscellaneous module data
...
...
@@ -962,6 +962,7 @@ class Manager(object):
self
.
disable
=
0
self
.
emittedNoHandlerWarning
=
0
self
.
loggerDict
=
{}
self
.
loggerClass
=
None
def
getLogger
(
self
,
name
):
"""
...
...
@@ -981,13 +982,13 @@ class Manager(object):
rv
=
self
.
loggerDict
[
name
]
if
isinstance
(
rv
,
PlaceHolder
):
ph
=
rv
rv
=
_loggerClass
(
name
)
rv
=
(
self
.
loggerClass
or
_loggerClass
)
(
name
)
rv
.
manager
=
self
self
.
loggerDict
[
name
]
=
rv
self
.
_fixupChildren
(
ph
,
rv
)
self
.
_fixupParents
(
rv
)
else
:
rv
=
_loggerClass
(
name
)
rv
=
(
self
.
loggerClass
or
_loggerClass
)
(
name
)
rv
.
manager
=
self
self
.
loggerDict
[
name
]
=
rv
self
.
_fixupParents
(
rv
)
...
...
@@ -995,6 +996,16 @@ class Manager(object):
_releaseLock
()
return
rv
def
setLoggerClass
(
self
,
klass
):
"""
Set the class to be used when instantiating a logger with this Manager.
"""
if
klass
!=
Logger
:
if
not
issubclass
(
klass
,
Logger
):
raise
TypeError
(
"logger not derived from logging.Logger: "
+
klass
.
__name__
)
self
.
loggerClass
=
klass
def
_fixupParents
(
self
,
alogger
):
"""
Ensure that there are either loggers or placeholders all the way
...
...
Lib/test/test_logging.py
Dosyayı görüntüle @
657514a6
...
...
@@ -1593,7 +1593,6 @@ class ConfigDictTest(BaseTest):
logging
.
config
.
stopListening
()
t
.
join
(
2.0
)
#@unittest.skip("See issue #7857")
def
test_listen_config_10_ok
(
self
):
with
captured_stdout
()
as
output
:
self
.
setup_via_listener
(
json
.
dumps
(
self
.
config10
))
...
...
@@ -1613,7 +1612,6 @@ class ConfigDictTest(BaseTest):
(
'ERROR'
,
'4'
),
],
stream
=
output
)
#@unittest.skip("See issue #7857")
def
test_listen_config_1_ok
(
self
):
with
captured_stdout
()
as
output
:
self
.
setup_via_listener
(
textwrap
.
dedent
(
ConfigFileTest
.
config1
))
...
...
@@ -1629,15 +1627,34 @@ class ConfigDictTest(BaseTest):
self
.
assert_log_lines
([])
class
ManagerTest
(
BaseTest
):
def
test_manager_loggerclass
(
self
):
logged
=
[]
class
MyLogger
(
logging
.
Logger
):
def
_log
(
self
,
level
,
msg
,
args
,
exc_info
=
None
,
extra
=
None
):
logged
.
append
(
msg
)
man
=
logging
.
Manager
(
None
)
self
.
assertRaises
(
TypeError
,
man
.
setLoggerClass
,
int
)
man
.
setLoggerClass
(
MyLogger
)
logger
=
man
.
getLogger
(
'test'
)
print
>>
open
(
'/tmp/tmp.txt'
,
'w'
),
type
(
logger
)
logger
.
warning
(
'should appear in logged'
)
logging
.
warning
(
'should not appear in logged'
)
self
.
assertEqual
(
logged
,
[
'should appear in logged'
])
# 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.
@run_with_locale
(
'LC_ALL'
,
''
)
def
test_main
():
run_unittest
(
BuiltinLevelsTest
,
BasicFilterTest
,
CustomLevelsAndFiltersTest
,
MemoryHandlerTest
,
ConfigFileTest
,
SocketHandlerTest
,
MemoryTest
,
EncodingTest
,
WarningsTest
,
ConfigDict
Test
)
CustomLevelsAndFiltersTest
,
MemoryHandlerTest
,
ConfigFileTest
,
SocketHandlerTest
,
MemoryTest
,
EncodingTest
,
WarningsTest
,
ConfigDictTest
,
Manager
Test
)
if
__name__
==
"__main__"
:
test_main
()
Misc/NEWS
Dosyayı görüntüle @
657514a6
...
...
@@ -75,6 +75,8 @@ Core and Builtins
Library
-------
- Issue #7868: logging: added loggerClass attribute to Manager.
- Issue #7851: logging: clarification on logging configuration files.
- Issue #4772: Raise a ValueError when an unknown Bluetooth protocol is
...
...
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