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
57c22379
Commit
57c22379
authored
Feb 23, 2012
by
Vinay Sajip
Browse files
Options
Browse Files
Download
Plain Diff
Merged logging flush/close changes from 3.2.
parents
c4c90bdf
0abf61db
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
33 additions
and
27 deletions
+33
-27
Lib/logging/__init__.py
Lib/logging/__init__.py
+12
-10
Lib/logging/handlers.py
Lib/logging/handlers.py
+21
-17
No files found.
Lib/logging/__init__.py
View file @
57c22379
...
@@ -16,9 +16,9 @@
...
@@ -16,9 +16,9 @@
"""
"""
Logging package for Python. Based on PEP 282 and comments thereto in
Logging package for Python. Based on PEP 282 and comments thereto in
comp.lang.python
, and influenced by Apache's log4j system
.
comp.lang.python.
Copyright (C) 2001-201
1
Vinay Sajip. All Rights Reserved.
Copyright (C) 2001-201
2
Vinay Sajip. All Rights Reserved.
To use, simply 'import logging' and log away!
To use, simply 'import logging' and log away!
"""
"""
...
@@ -914,8 +914,9 @@ class StreamHandler(Handler):
...
@@ -914,8 +914,9 @@ class StreamHandler(Handler):
"""
"""
Flushes the stream.
Flushes the stream.
"""
"""
if
self
.
stream
and
hasattr
(
self
.
stream
,
"flush"
):
with
self
.
lock
:
self
.
stream
.
flush
()
if
self
.
stream
and
hasattr
(
self
.
stream
,
"flush"
):
self
.
stream
.
flush
()
def
emit
(
self
,
record
):
def
emit
(
self
,
record
):
"""
"""
...
@@ -964,12 +965,13 @@ class FileHandler(StreamHandler):
...
@@ -964,12 +965,13 @@ class FileHandler(StreamHandler):
"""
"""
Closes the stream.
Closes the stream.
"""
"""
if
self
.
stream
:
with
self
.
lock
:
self
.
flush
()
if
self
.
stream
:
if
hasattr
(
self
.
stream
,
"close"
):
self
.
flush
()
self
.
stream
.
close
()
if
hasattr
(
self
.
stream
,
"close"
):
StreamHandler
.
close
(
self
)
self
.
stream
.
close
()
self
.
stream
=
None
StreamHandler
.
close
(
self
)
self
.
stream
=
None
def
_open
(
self
):
def
_open
(
self
):
"""
"""
...
...
Lib/logging/handlers.py
View file @
57c22379
# Copyright 2001-201
0
by Vinay Sajip. All Rights Reserved.
# Copyright 2001-201
2
by Vinay Sajip. All Rights Reserved.
#
#
# Permission to use, copy, modify, and distribute this software and its
# Permission to use, copy, modify, and distribute this software and its
# documentation for any purpose and without fee is hereby granted,
# documentation for any purpose and without fee is hereby granted,
...
@@ -16,10 +16,9 @@
...
@@ -16,10 +16,9 @@
"""
"""
Additional handlers for the logging package for Python. The core package is
Additional handlers for the logging package for Python. The core package is
based on PEP 282 and comments thereto in comp.lang.python, and influenced by
based on PEP 282 and comments thereto in comp.lang.python.
Apache's log4j system.
Copyright (C) 2001-201
0
Vinay Sajip. All Rights Reserved.
Copyright (C) 2001-201
2
Vinay Sajip. All Rights Reserved.
To use, simply 'import logging.handlers' and log away!
To use, simply 'import logging.handlers' and log away!
"""
"""
...
@@ -594,10 +593,11 @@ class SocketHandler(logging.Handler):
...
@@ -594,10 +593,11 @@ class SocketHandler(logging.Handler):
"""
"""
Closes the socket.
Closes the socket.
"""
"""
if
self
.
sock
:
with
self
.
lock
:
self
.
sock
.
close
()
if
self
.
sock
:
self
.
sock
=
None
self
.
sock
.
close
()
logging
.
Handler
.
close
(
self
)
self
.
sock
=
None
logging
.
Handler
.
close
(
self
)
class
DatagramHandler
(
SocketHandler
):
class
DatagramHandler
(
SocketHandler
):
"""
"""
...
@@ -792,8 +792,9 @@ class SysLogHandler(logging.Handler):
...
@@ -792,8 +792,9 @@ class SysLogHandler(logging.Handler):
"""
"""
Closes the socket.
Closes the socket.
"""
"""
self
.
socket
.
close
()
with
self
.
lock
:
logging
.
Handler
.
close
(
self
)
self
.
socket
.
close
()
logging
.
Handler
.
close
(
self
)
def
mapPriority
(
self
,
levelName
):
def
mapPriority
(
self
,
levelName
):
"""
"""
...
@@ -1137,7 +1138,8 @@ class BufferingHandler(logging.Handler):
...
@@ -1137,7 +1138,8 @@ class BufferingHandler(logging.Handler):
This version just zaps the buffer to empty.
This version just zaps the buffer to empty.
"""
"""
self
.
buffer
=
[]
with
self
.
lock
:
self
.
buffer
=
[]
def
close
(
self
):
def
close
(
self
):
"""
"""
...
@@ -1187,18 +1189,20 @@ class MemoryHandler(BufferingHandler):
...
@@ -1187,18 +1189,20 @@ class MemoryHandler(BufferingHandler):
The record buffer is also cleared by this operation.
The record buffer is also cleared by this operation.
"""
"""
if
self
.
target
:
with
self
.
lock
:
for
record
in
self
.
buffer
:
if
self
.
target
:
self
.
target
.
handle
(
record
)
for
record
in
self
.
buffer
:
self
.
buffer
=
[]
self
.
target
.
handle
(
record
)
self
.
buffer
=
[]
def
close
(
self
):
def
close
(
self
):
"""
"""
Flush, set the target to None and lose the buffer.
Flush, set the target to None and lose the buffer.
"""
"""
self
.
flush
()
self
.
flush
()
self
.
target
=
None
with
self
.
lock
:
BufferingHandler
.
close
(
self
)
self
.
target
=
None
BufferingHandler
.
close
(
self
)
class
QueueHandler
(
logging
.
Handler
):
class
QueueHandler
(
logging
.
Handler
):
...
...
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