Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cpython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
cpython
Commits
3ab905f1
Commit
3ab905f1
authored
Sep 27, 2010
by
Vinay Sajip
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Issue #9945: logging: backported locking fixes from py3k.
parent
af08f935
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
39 additions
and
37 deletions
+39
-37
Lib/logging/__init__.py
Lib/logging/__init__.py
+39
-37
No files found.
Lib/logging/__init__.py
View file @
3ab905f1
...
...
@@ -1180,20 +1180,23 @@ class Logger(Filterer):
"""
Add the specified handler to this logger.
"""
if
not
(
hdlr
in
self
.
handlers
):
self
.
handlers
.
append
(
hdlr
)
_acquireLock
()
try
:
if
not
(
hdlr
in
self
.
handlers
):
self
.
handlers
.
append
(
hdlr
)
finally
:
_releaseLock
()
def
removeHandler
(
self
,
hdlr
):
"""
Remove the specified handler from this logger.
"""
if
hdlr
in
self
.
handlers
:
#hdlr.close()
hdlr
.
acquire
()
try
:
_acquireLock
()
try
:
if
hdlr
in
self
.
handlers
:
self
.
handlers
.
remove
(
hdlr
)
finally
:
hdlr
.
release
()
finally
:
_releaseLock
()
def
callHandlers
(
self
,
record
):
"""
...
...
@@ -1389,26 +1392,28 @@ def basicConfig(**kwargs):
using sys.stdout or sys.stderr), whereas FileHandler closes its stream
when the handler is closed.
"""
if
len
(
root
.
handlers
)
==
0
:
filename
=
kwargs
.
get
(
"filename"
)
if
filename
:
mode
=
kwargs
.
get
(
"filemode"
,
'a'
)
hdlr
=
FileHandler
(
filename
,
mode
)
else
:
stream
=
kwargs
.
get
(
"stream"
)
hdlr
=
StreamHandler
(
stream
)
fs
=
kwargs
.
get
(
"format"
,
BASIC_FORMAT
)
dfs
=
kwargs
.
get
(
"datefmt"
,
None
)
fmt
=
Formatter
(
fs
,
dfs
)
hdlr
.
setFormatter
(
fmt
)
root
.
addHandler
(
hdlr
)
level
=
kwargs
.
get
(
"level"
)
if
level
is
not
None
:
if
str
(
level
)
==
level
:
# If a string was passed, do more checks
if
level
not
in
_levelNames
:
raise
ValueError
(
"Unknown level: %r"
%
level
)
level
=
_levelNames
[
level
]
root
.
setLevel
(
level
)
# Add thread safety in case someone mistakenly calls
# basicConfig() from multiple threads
_acquireLock
()
try
:
if
len
(
root
.
handlers
)
==
0
:
filename
=
kwargs
.
get
(
"filename"
)
if
filename
:
mode
=
kwargs
.
get
(
"filemode"
,
'a'
)
hdlr
=
FileHandler
(
filename
,
mode
)
else
:
stream
=
kwargs
.
get
(
"stream"
)
hdlr
=
StreamHandler
(
stream
)
fs
=
kwargs
.
get
(
"format"
,
BASIC_FORMAT
)
dfs
=
kwargs
.
get
(
"datefmt"
,
None
)
fmt
=
Formatter
(
fs
,
dfs
)
hdlr
.
setFormatter
(
fmt
)
root
.
addHandler
(
hdlr
)
level
=
kwargs
.
get
(
"level"
)
if
level
is
not
None
:
root
.
setLevel
(
level
)
finally
:
_releaseLock
()
#---------------------------------------------------------------------------
# Utility functions at module level.
...
...
@@ -1426,15 +1431,6 @@ def getLogger(name=None):
else
:
return
root
#def getRootLogger():
# """
# Return the root logger.
#
# Note that getLogger('') now does the same thing, so this function is
# deprecated and may disappear in the future.
# """
# return root
def
critical
(
msg
,
*
args
,
**
kwargs
):
"""
Log a message with severity 'CRITICAL' on the root logger.
...
...
@@ -1543,9 +1539,15 @@ class NullHandler(Handler):
a NullHandler and add it to the top-level logger of the library module or
package.
"""
def
handle
(
self
,
record
):
pass
def
emit
(
self
,
record
):
pass
def
createLock
(
self
):
self
.
lock
=
None
# Warnings integration
_warnings_showwarning
=
None
...
...
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