Reformatting kafka logs
Change-Id: I853d3db2324c6cf96ccd5c7d08fe295299e38688
diff --git a/common/utils/consulhelpers.py b/common/utils/consulhelpers.py
index 1d2b88f..681aaf4 100644
--- a/common/utils/consulhelpers.py
+++ b/common/utils/consulhelpers.py
@@ -28,8 +28,9 @@
def get_endpoint_from_consul(consul_endpoint, service_name):
"""Look up, from consul, the service name specified by service-name
"""
- log.debug('Retrieving endpoint {} from consul {}'.format(service_name,
- consul_endpoint))
+ log.debug('getting-service-endpoint', consul=consul_endpoint,
+ service=service_name)
+
host = consul_endpoint.split(':')[0].strip()
port = int(consul_endpoint.split(':')[1].strip())
diff --git a/common/utils/dockerhelpers.py b/common/utils/dockerhelpers.py
index 9379e2d..89acab6 100644
--- a/common/utils/dockerhelpers.py
+++ b/common/utils/dockerhelpers.py
@@ -80,7 +80,7 @@
docker_cli = Client(base_url=docker_socket)
info = docker_cli.inspect_container(id)
except Exception, e:
- log.debug('failed: {}'.format(e.message))
+ log.exception('failed-inspect-container', id=id, e=e)
raise
return info
@@ -94,7 +94,7 @@
host_config = docker_cli.create_host_config(binds=binds,
port_bindings=port_bindings)
except Exception, e:
- log.exception('failed host config creation', volumes, ports, e=e)
+ log.exception('failed-host-config-creation', volumes, ports, e=e)
raise
return host_config
@@ -103,8 +103,9 @@
try:
docker_cli = Client(base_url=docker_socket)
docker_cli.connect_container_to_network(container, net_id, links=links)
- except:
- log.exception('Failed to connect container {} to network {}'.format(container, net_id))
+ except Exception, e:
+ log.exception('failed-connection-to-network',
+ container=container, net_id=net_id, e=e)
raise
def create_networking_config(name, links):
@@ -120,7 +121,7 @@
name : docker_cli.create_endpoint_config(links=links)
})
except Exception, e:
- log.exception('failed network creation', name, e=e)
+ log.exception('failed-network-creation', name, e=e)
raise
return networking_config
@@ -165,7 +166,7 @@
def __init__(self, threads=1):
self.client = CustomClient(base_url=docker_socket)
self.events = self.client.events(decode=True)
- log.info("Starting event processor with {} threads".format(threads))
+ log.info("starting", threads=threads)
self.exec_service = ThreadPoolExecutor(max_workers=threads)
def stop_listening(self):
@@ -200,7 +201,7 @@
for k in ['time', 'Time']:
if k in event:
event[k] = datetime.fromtimestamp(event[k])
- log.debug('docker event: {}'.format(event))
+ log.debug('docker-event', event=event)
data = {}
i = get_id(event)
@@ -212,14 +213,14 @@
data = self.client.inspect_image(i)
data[i] = data
except errors.NotFound:
- log.debug('No data for container {}'.format(i))
+ log.debug('no-data-for-container', container=i)
status = get_status(event)
if status in handlers:
self.exec_service.submit(handlers[get_status(event)], event,
data, handlers['podder_config'])
else:
- log.debug("No handler for {}; skipping...".format(status))
+ log.debug('no-handler', handler=status)
class CustomGenerator(object):
"""