From 510973e1cdbb03a640e890dd3afecbaeeaf72ff2 Mon Sep 17 00:00:00 2001 From: Ralph Bean Date: Thu, 27 Feb 2014 15:05:34 +0000 Subject: [PATCH] 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. --- roles/fedmsg_base/templates/logging.py.j2 | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/roles/fedmsg_base/templates/logging.py.j2 b/roles/fedmsg_base/templates/logging.py.j2 index c2d634bb70..de0fe02f42 100644 --- a/roles/fedmsg_base/templates/logging.py.j2 +++ b/roles/fedmsg_base/templates/logging.py.j2 @@ -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]