Determine process at log-time, not startup-time.

This is because things like the fedmsg-hub are daemons, and will double-fork
into the background.  If we determine the process at startup time, that original
process is long dead by the time we get to the first log statement.
This commit is contained in:
Ralph Bean 2014-02-27 15:05:34 +00:00
parent 0b54cd4623
commit 510973e1cd

View file

@ -27,6 +27,9 @@ class ContextInjector(logging.Filter):
"""
def filter(self, record):
current_process = ContextInjector.get_current_process()
current_hostname = socket.gethostname()
record.host = current_hostname
record.proc = current_process
record.pid = current_process.pid
@ -67,9 +70,6 @@ class ContextInjector(logging.Filter):
return {'name': 'ContextInjector'}
current_process = ContextInjector.get_current_process()
current_hostname = socket.gethostname()
hefty_format = """Message
-------
[%(asctime)s][%(name)10s %(levelname)7s]