summaryrefslogtreecommitdiffstats
path: root/Lib/logging/handlers.py
diff options
context:
space:
mode:
authorVinay Sajip <vinay_sajip@yahoo.co.uk>2012-02-23 20:03:49 (GMT)
committerVinay Sajip <vinay_sajip@yahoo.co.uk>2012-02-23 20:03:49 (GMT)
commit57c223791de6edb7fd302bd682630ab1e259a06b (patch)
tree66db8e9c712e845a2debbd1befc08e5a2c442f5f /Lib/logging/handlers.py
parentc4c90bdf202e9b6d088b7f5a38789b211d9d0a29 (diff)
parent0abf61db4dd0d008ad06c84cd882fb84e5c11181 (diff)
downloadcpython-57c223791de6edb7fd302bd682630ab1e259a06b.zip
cpython-57c223791de6edb7fd302bd682630ab1e259a06b.tar.gz
cpython-57c223791de6edb7fd302bd682630ab1e259a06b.tar.bz2
Merged logging flush/close changes from 3.2.
Diffstat (limited to 'Lib/logging/handlers.py')
-rw-r--r--Lib/logging/handlers.py38
1 files changed, 21 insertions, 17 deletions
diff --git a/Lib/logging/handlers.py b/Lib/logging/handlers.py
index 822b4ef..0107853 100644
--- a/Lib/logging/handlers.py
+++ b/Lib/logging/handlers.py
@@ -1,4 +1,4 @@
-# Copyright 2001-2010 by Vinay Sajip. All Rights Reserved.
+# Copyright 2001-2012 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,
@@ -16,10 +16,9 @@
"""
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
-Apache's log4j system.
+based on PEP 282 and comments thereto in comp.lang.python.
-Copyright (C) 2001-2010 Vinay Sajip. All Rights Reserved.
+Copyright (C) 2001-2012 Vinay Sajip. All Rights Reserved.
To use, simply 'import logging.handlers' and log away!
"""
@@ -594,10 +593,11 @@ class SocketHandler(logging.Handler):
"""
Closes the socket.
"""
- if self.sock:
- self.sock.close()
- self.sock = None
- logging.Handler.close(self)
+ with self.lock:
+ if self.sock:
+ self.sock.close()
+ self.sock = None
+ logging.Handler.close(self)
class DatagramHandler(SocketHandler):
"""
@@ -792,8 +792,9 @@ class SysLogHandler(logging.Handler):
"""
Closes the socket.
"""
- self.socket.close()
- logging.Handler.close(self)
+ with self.lock:
+ self.socket.close()
+ logging.Handler.close(self)
def mapPriority(self, levelName):
"""
@@ -1137,7 +1138,8 @@ class BufferingHandler(logging.Handler):
This version just zaps the buffer to empty.
"""
- self.buffer = []
+ with self.lock:
+ self.buffer = []
def close(self):
"""
@@ -1187,18 +1189,20 @@ class MemoryHandler(BufferingHandler):
The record buffer is also cleared by this operation.
"""
- if self.target:
- for record in self.buffer:
- self.target.handle(record)
- self.buffer = []
+ with self.lock:
+ if self.target:
+ for record in self.buffer:
+ self.target.handle(record)
+ self.buffer = []
def close(self):
"""
Flush, set the target to None and lose the buffer.
"""
self.flush()
- self.target = None
- BufferingHandler.close(self)
+ with self.lock:
+ self.target = None
+ BufferingHandler.close(self)
class QueueHandler(logging.Handler):