From 058e327c5945f0208a147871ba54b73b5fa8d8ff Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mr=C2=B7x?= Date: Tue, 2 Mar 2021 13:40:27 +0800 Subject: [PATCH] =?UTF-8?q?=E6=94=B9=E5=90=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- System/Error/Logger.php | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/System/Error/Logger.php b/System/Error/Logger.php index fc957d02..24b7f517 100644 --- a/System/Error/Logger.php +++ b/System/Error/Logger.php @@ -10,6 +10,7 @@ declare(strict_types=1); namespace Snowflake\Error; use Exception; +use HttpServer\Http\Context; use Snowflake\Abstracts\Component; use Snowflake\Abstracts\Config; use Snowflake\Core\Json; @@ -166,7 +167,8 @@ class Logger extends Component $files = glob(storage(null, $dirName) . '/*'); if (count($files) >= 15) { - shell_exec('find ' . storage(null, $dirName) . '/ -mtime +15 -name "*.log" -exec rm -rf {} \;'); + $command = 'find ' . storage(null, $dirName) . '/ -mtime +15 -name "*.log" -exec rm -rf {} \;'; + Context::inCoroutine() ? Coroutine\System::exec($command) : exec($command); } } @@ -177,7 +179,7 @@ class Logger extends Component private function getSource($logFile): string { if (!file_exists($logFile)) { - shell_exec('echo 3 > /proc/sys/vm/drop_caches'); + Coroutine\System::exec('echo 3 > /proc/sys/vm/drop_caches'); touch($logFile); } if (is_writeable($logFile)) {