mirror of
https://github.com/python/cpython.git
synced 2025-08-04 17:08:35 +00:00
merge cl r68737 to py3k
This commit is contained in:
parent
e1cdfd78d8
commit
9a0fc97bf4
3 changed files with 13 additions and 24 deletions
|
@ -69,34 +69,10 @@ def get_logger():
|
|||
atexit._exithandlers.remove((_exit_function, (), {}))
|
||||
atexit._exithandlers.append((_exit_function, (), {}))
|
||||
|
||||
_check_logger_class()
|
||||
_logger = logging.getLogger(LOGGER_NAME)
|
||||
|
||||
return _logger
|
||||
|
||||
def _check_logger_class():
|
||||
'''
|
||||
Make sure process name is recorded when loggers are used
|
||||
'''
|
||||
# XXX This function is unnecessary once logging is patched
|
||||
import logging
|
||||
if hasattr(logging, 'multiprocessing'):
|
||||
return
|
||||
|
||||
logging._acquireLock()
|
||||
try:
|
||||
OldLoggerClass = logging.getLoggerClass()
|
||||
if not getattr(OldLoggerClass, '_process_aware', False):
|
||||
class ProcessAwareLogger(OldLoggerClass):
|
||||
_process_aware = True
|
||||
def makeRecord(self, *args, **kwds):
|
||||
record = OldLoggerClass.makeRecord(self, *args, **kwds)
|
||||
record.processName = current_process()._name
|
||||
return record
|
||||
logging.setLoggerClass(ProcessAwareLogger)
|
||||
finally:
|
||||
logging._releaseLock()
|
||||
|
||||
def log_to_stderr(level=None):
|
||||
'''
|
||||
Turn on logging and add a handler which prints to stderr
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue