small logging changes

This commit is contained in:
Luna Mendes 2018-08-08 19:37:57 -03:00
parent d36d3d7449
commit 3dd37c0bf1
3 changed files with 12 additions and 6 deletions

View File

@ -57,7 +57,7 @@ class PingAdapter(Adapter):
else:
latency = 0
worker.log.info(f'{worker.name}: alive={alive} latency={latency}ms')
worker.log.info(f'alive={alive} latency={latency}ms')
return cls._construct(alive, latency)
@ -79,8 +79,7 @@ class HttpAdapter(Adapter):
latency = round((t_end - t_start) * 1000)
worker.log.info(f'{worker.name}: status={resp.status} '
f'latency={latency}ms')
worker.log.info(f'status={resp.status} latency={latency}ms')
if resp.status == 200:
return cls._construct(True, latency)

View File

@ -107,5 +107,5 @@ async def streaming_ws(request, ws):
await ws.ping()
await asyncio.sleep(1)
except websockets.exceptions.ConnectionClosed as wc:
log.warning(f'connection {ws.client_id} closed: {wc!r}')
log.warning(f'conn {ws.client_id} closed: {wc.code} {wc.reason!r}')
request.app.manager.unsub_all(ws)

View File

@ -137,10 +137,12 @@ class ServiceManager:
pass
log.info(f'unsubscribed {websocket.client_id} from {unsub}')
try:
self._websockets.pop(websocket.client_id)
except KeyError:
pass
return unsub
def _ws_send(self, websocket, data: Any):
@ -166,8 +168,13 @@ class ServiceManager:
def _send(websocket):
return self._raw_send(websocket, channel, data)
tasks = map(_send, websockets)
return list(tasks)
tasks = list(map(_send, websockets))
clients = len(tasks)
if clients:
log.info(f'Dispatching on {channel} to {clients} clients')
return tasks
def publish_incident(self, op: int, data: Any):
ws_ids = self.subscribers['incidents']