Skip to content

Commit

Permalink
Windows does not support exclusive locks on stdout
Browse files Browse the repository at this point in the history
  • Loading branch information
staabm authored and sebastianbergmann committed Mar 28, 2024
1 parent 406a2b4 commit 5e80471
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/Logging/EventLogger.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,16 @@ public function trace(Event $event): void
$indentation = PHP_EOL . str_repeat(' ', strlen($telemetryInfo));
$lines = preg_split('/\r\n|\r|\n/', $event->asString());

$flags = FILE_APPEND;

if (PHP_OS_FAMILY !== 'Windows' || $this->path !== 'php://stdout') {
$flags |= LOCK_EX;
}

file_put_contents(
$this->path,
$telemetryInfo . implode($indentation, $lines) . PHP_EOL,
FILE_APPEND | LOCK_EX,
$flags,
);
}

Expand Down

0 comments on commit 5e80471

Please sign in to comment.