Skip to content

Commit

Permalink
Add some useful hashtags on the LISTENER related messages.
Browse files Browse the repository at this point in the history
  • Loading branch information
NickALafrance committed Apr 27, 2020
1 parent 702e9dc commit 596dd08
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions Salesforce/Inbound/SObjectConsumer.php
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,10 @@ public function consume(ChannelInterface $channel, Message $message)
$data = $message->getData();
$replayId = $data->getEvent()->getReplayId();

$sObject = substr($this->getSfidFromData($data), 0, 3);

$this->logger->debug(
"LISTENER RECEIVED $replayId: Channel `{channel}` | {data}",
"#LISTENER RECEIVED #$sObject $replayId: Channel `{channel}` | {data}",
[
'channel' => $channel->getChannelId(),
'data' => $message->getData(),
Expand All @@ -84,7 +86,7 @@ public function consume(ChannelInterface $channel, Message $message)
}
}

$this->logger->debug("LISTENER COMPLETE $replayId");
$this->logger->debug("#LISTENER COMPLETE #$sObject $replayId");

$stop = microtime(true);
$this->throughputCalculations = $this->throughPut($this->throughputCalculations, $stop - $start, $this->getSfidFromData($data));
Expand Down Expand Up @@ -154,14 +156,17 @@ private function throughPut(array $throughputCalculations, $time, ?string $sfid
return $throughputCalculations;
}

private function getSfidFromData(StreamingData $data): ?string
private function getSfidFromData(?StreamingData $data): string
{
if (!$data) {
return 'N/A';
}
if (null !== $data->getSobject()) {
return $data->getSobject()->getId();
} elseif (null !== $data->getPayload() && is_array($data->getPayload())) {
return $data->getPayload()['ChangeEventHeader']['recordIds'][0];
}
return null;
return 'N/A';
}

public function setMemoryLimit(int $limit)
Expand Down

0 comments on commit 596dd08

Please sign in to comment.