Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 4a70486

Browse files
committed
Added threadName and now using re-entrant lock
1 parent a6e8a4a commit 4a70486

1 file changed

Lines changed: 5 additions & 2 deletions

File tree

Lib/logging/__init__.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@
4242
__author__ = "Vinay Sajip <[email protected]>"
4343
__status__ = "beta"
4444
__version__ = "0.4.9.6"
45-
__date__ = "12 March 2005"
45+
__date__ = "27 March 2005"
4646

4747
#---------------------------------------------------------------------------
4848
# Miscellaneous module data
@@ -241,8 +241,10 @@ def __init__(self, name, level, pathname, lineno, msg, args, exc_info):
241241
self.relativeCreated = (self.created - _startTime) * 1000
242242
if thread:
243243
self.thread = thread.get_ident()
244+
self.threadName = threading.currentThread().getName()
244245
else:
245246
self.thread = None
247+
self.threadName = None
246248
if hasattr(os, 'getpid'):
247249
self.process = os.getpid()
248250
else:
@@ -320,6 +322,7 @@ class Formatter:
320322
relative to the time the logging module was loaded
321323
(typically at application startup time)
322324
%(thread)d Thread ID (if available)
325+
%(threadName)s Thread name (if available)
323326
%(process)d Process ID (if available)
324327
%(message)s The result of record.getMessage(), computed just as
325328
the record is emitted
@@ -570,7 +573,7 @@ def createLock(self):
570573
Acquire a thread lock for serializing access to the underlying I/O.
571574
"""
572575
if thread:
573-
self.lock = thread.allocate_lock()
576+
self.lock = threading.RLock()
574577
else:
575578
self.lock = None
576579

0 commit comments

Comments
 (0)