include function name in log message

pull/988/head
Ryan Tharp 6 years ago
parent e4d762a358
commit 6bdc269081

@ -152,7 +152,7 @@ class LokiMessageAPI {
'Ran out of swarm nodes to query' 'Ran out of swarm nodes to query'
); );
} }
log.info(`loki_message: Successfully stored message to ${pubKey}`); log.info(`loki_message:::sendMessage - Successfully stored message to ${pubKey}`);
} }
async refreshSendingSwarm(pubKey, timestamp) { async refreshSendingSwarm(pubKey, timestamp) {
@ -216,7 +216,7 @@ class LokiMessageAPI {
return true; return true;
} catch (e) { } catch (e) {
log.warn( log.warn(
'loki_message: send error:', 'loki_message:::_sendToNode - send error:',
e.code, e.code,
e.message, e.message,
`destination ${targetNode.ip}:${targetNode.port}` `destination ${targetNode.ip}:${targetNode.port}`
@ -236,12 +236,12 @@ class LokiMessageAPI {
} else if (e instanceof textsecure.NotFoundError) { } else if (e instanceof textsecure.NotFoundError) {
// TODO: Handle resolution error // TODO: Handle resolution error
} else if (e instanceof textsecure.TimestampError) { } else if (e instanceof textsecure.TimestampError) {
log.warn('loki_message: Timestamp is invalid'); log.warn('loki_message:::_sendToNode - Timestamp is invalid');
throw e; throw e;
} else if (e instanceof textsecure.HTTPError) { } else if (e instanceof textsecure.HTTPError) {
// TODO: Handle working connection but error response // TODO: Handle working connection but error response
const body = await e.response.text(); const body = await e.response.text();
log.warn('loki_message: HTTPError body:', body); log.warn('loki_message:::_sendToNode - HTTPError body:', body);
} }
successiveFailures += 1; successiveFailures += 1;
} }
@ -251,7 +251,7 @@ class LokiMessageAPI {
targetNode targetNode
); );
log.error( log.error(
`loki_message: Too many successive failures trying to send to node ${ `loki_message:::_sendToNode - Too many successive failures trying to send to node ${
targetNode.ip targetNode.ip
}:${targetNode.port}, ${remainingSwarmSnodes.lengt} remaining swarm nodes` }:${targetNode.port}, ${remainingSwarmSnodes.lengt} remaining swarm nodes`
); );
@ -307,7 +307,7 @@ class LokiMessageAPI {
callback(messages); callback(messages);
} catch (e) { } catch (e) {
log.warn( log.warn(
'loki_message: retrieve error:', 'loki_message:::_openRetrieveConnection - retrieve error:',
e.code, e.code,
e.message, e.message,
`on ${nodeData.ip}:${nodeData.port}` `on ${nodeData.ip}:${nodeData.port}`
@ -340,7 +340,7 @@ class LokiMessageAPI {
nodeData nodeData
); );
log.warn( log.warn(
`loki_message: removing ${nodeData.ip}:${ `loki_message:::_openRetrieveConnection - too many successive failures, removing ${nodeData.ip}:${
nodeData.port nodeData.port
} from our swarm pool. We have ${ } from our swarm pool. We have ${
Object.keys(this.ourSwarmNodes).length Object.keys(this.ourSwarmNodes).length
@ -353,7 +353,7 @@ class LokiMessageAPI {
// if not stopPollingResult // if not stopPollingResult
if (_.isEmpty(this.ourSwarmNodes)) { if (_.isEmpty(this.ourSwarmNodes)) {
log.error( log.error(
'loki_message: We no longer have any swarm nodes available to try in pool, closing retrieve connection' 'loki_message:::_openRetrieveConnection - We no longer have any swarm nodes available to try in pool, closing retrieve connection'
); );
return false; return false;
} }
@ -396,18 +396,18 @@ class LokiMessageAPI {
let nodes = await lokiSnodeAPI.getSwarmNodesForPubKey(this.ourKey); let nodes = await lokiSnodeAPI.getSwarmNodesForPubKey(this.ourKey);
if (nodes.length < numConnections) { if (nodes.length < numConnections) {
log.warn( log.warn(
'loki_message: Not enough SwarmNodes for our pubkey in local database, getting current list from blockchain' 'loki_message:::startLongPolling - Not enough SwarmNodes for our pubkey in local database, getting current list from blockchain'
); );
// load from blockchain // load from blockchain
nodes = await lokiSnodeAPI.refreshSwarmNodesForPubKey(this.ourKey); nodes = await lokiSnodeAPI.refreshSwarmNodesForPubKey(this.ourKey);
if (nodes.length < numConnections) { if (nodes.length < numConnections) {
log.error( log.error(
'loki_message: Could not get enough SwarmNodes for our pubkey from blockchain' 'loki_message:::startLongPolling - Could not get enough SwarmNodes for our pubkey from blockchain'
); );
} }
} }
log.info( log.info(
'loki_message: startLongPolling for', 'loki_message:::startLongPolling - start polling for',
numConnections, numConnections,
'connections. We have swarmNodes', 'connections. We have swarmNodes',
nodes.length, nodes.length,
@ -438,7 +438,7 @@ class LokiMessageAPI {
this._openRetrieveConnection(stopPolling, callback).then(() => { this._openRetrieveConnection(stopPolling, callback).then(() => {
unresolved -= 1; unresolved -= 1;
log.info( log.info(
'loki_message: There are', 'loki_message:::startLongPolling - There are',
unresolved, unresolved,
'open retrieve connections left' 'open retrieve connections left'
); );
@ -451,7 +451,7 @@ class LokiMessageAPI {
// or if there is network issues (ENOUTFOUND due to lokinet) // or if there is network issues (ENOUTFOUND due to lokinet)
await Promise.all(promises); await Promise.all(promises);
log.error( log.error(
'loki_message: All our long poll swarm connections have been removed' 'loki_message:::startLongPolling - All our long poll swarm connections have been removed'
); );
// should we just call ourself again? // should we just call ourself again?
// no, our caller already handles this... // no, our caller already handles this...

Loading…
Cancel
Save