Skip to content

Commit

Permalink
Optimization.
Browse files Browse the repository at this point in the history
  • Loading branch information
halilcosdu committed Apr 16, 2024
1 parent e43fb9c commit a23a5cf
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/LogWeaver.php
Original file line number Diff line number Diff line change
Expand Up @@ -180,11 +180,13 @@ private function waitForContentFromDisk(string $path): void
*/
public function log(?string $path = null, bool $wait = false): array
{
$storage = Storage::disk($this->getDisk());

if (is_null($path)) {
$path = sprintf('%s/%s.json', $this->getDirectory(), Str::random(40));
}

$check = Storage::disk($this->getDisk())->put($path, json_encode($this->getValidatedData()));
$check = $storage->put($path, json_encode($this->getValidatedData()));

if ($wait) {
$this->waitForContentFromDisk($path);
Expand All @@ -193,7 +195,7 @@ public function log(?string $path = null, bool $wait = false): array
return [
'status' => $check,
'path' => $path,
'url' => $check ? Storage::disk($this->getDisk())->url($path) : null,
'url' => $check ? $storage->url($path) : null,
];
}
}

0 comments on commit a23a5cf

Please sign in to comment.