From 5e80471d290e9eee21268ad3965284a5d82c95c5 Mon Sep 17 00:00:00 2001 From: Markus Staab Date: Tue, 26 Mar 2024 16:54:28 +0100 Subject: [PATCH] Windows does not support exclusive locks on stdout --- src/Logging/EventLogger.php | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/Logging/EventLogger.php b/src/Logging/EventLogger.php index ced39945f16..993ca5dffdc 100644 --- a/src/Logging/EventLogger.php +++ b/src/Logging/EventLogger.php @@ -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, ); }