From 21b425e32b42b6cd4a48dd2063bea7e2c4bed5aa Mon Sep 17 00:00:00 2001 From: Benjamin Renard Date: Wed, 1 Mar 2023 11:55:46 +0100 Subject: [PATCH] Log: when PHP cli-server is running, log on console --- src/Log.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Log.php b/src/Log.php index 9c9d061..a877459 100644 --- a/src/Log.php +++ b/src/Log.php @@ -198,10 +198,10 @@ class Log { $msg[] = $message; $msg = implode(' - ', $msg)."\n"; } - if (self :: $file_fd) + if (!self :: $file_fd || php_sapi_name() == 'cli-server') + error_log(rtrim($msg, "\n")); + else fwrite(self :: $file_fd, $msg); - elseif (self :: $error_log_fallback) - error_log($msg); if ($level == 'FATAL') if (!is_null(self :: $fatal_error_handler))