Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ function pd(): Client
$client = new Client();
}

// To not overwrite the last message again and again
$client->setLastMessageId();
return $client;
}
}
19 changes: 16 additions & 3 deletions src/Client.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,11 @@

class Client
{
/**
* @var string|null
*/
private $lastMessageId;

/**
* @var string
*/
Expand Down Expand Up @@ -47,7 +52,6 @@ public function log(... $arguments): self
$cloner->setMaxItems(-1);
$htmlDumper = new HtmlDumper();


foreach ($arguments as $argument) {
$data = $htmlDumper->dump($cloner->cloneVar($argument), true);
$msg->payload(new HtmlPayload($data));
Expand Down Expand Up @@ -182,6 +186,8 @@ public function send(Message $message): void

\curl_exec($ch);
\curl_close($ch);

$this->lastMessageId = $message->getId();
}

protected function createMessage(): Message
Expand All @@ -193,7 +199,7 @@ protected function createMessage(): Message
continue;
}

return new Message($this->stripPath($backtrace['file']), $backtrace['line']);
return new Message($this->stripPath($backtrace['file']), $backtrace['line'], $this->lastMessageId ?? null);
}

throw new \RuntimeException('Cannot detect entry point');
Expand All @@ -213,7 +219,7 @@ private function lockExists(string $id): bool
$resp = \curl_exec($ch);
\curl_close($ch);

return $resp === "1";
return $resp === '1';
}

private function stripPath(string $path): string
Expand All @@ -226,4 +232,11 @@ private function stripPath(string $path): string

return $path;
}

public function setLastMessageId(?string $lastMessageId = null): self
{
$this->lastMessageId = $lastMessageId;

return $this;
}
}
4 changes: 2 additions & 2 deletions src/Message/Message.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,9 @@ class Message extends Struct
*/
protected $payloads = [];

public function __construct(string $fileName, int $lineNumber)
public function __construct(string $fileName, int $lineNumber, ?string $uuid = null)
{
$this->uuid = Uuid::randomHex();
$this->uuid = $uuid ?? Uuid::randomHex();
$this->time = \microtime(true);
$this->origin = new Origin($fileName, $lineNumber);
}
Expand Down