From cedda65b183710a004f9f1fbedb16d07552aeded Mon Sep 17 00:00:00 2001 From: sunxyw <31698606+sunxyw@users.noreply.github.com> Date: Sat, 11 Feb 2023 22:15:02 +0800 Subject: [PATCH] improve schedule not supported notice (#298) --- src/ZM/Schedule/Schedule.php | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/ZM/Schedule/Schedule.php b/src/ZM/Schedule/Schedule.php index 586efd12..304cf300 100644 --- a/src/ZM/Schedule/Schedule.php +++ b/src/ZM/Schedule/Schedule.php @@ -25,9 +25,6 @@ class Schedule { $c = Adaptive::getCoroutine(); $this->available = $c instanceof CoroutineInterface; - if (!$this->available) { - logger()->error('排程任务只能在协程环境下使用'); - } } /** @@ -38,6 +35,8 @@ class Schedule public function addSchedule(Cron $cron): void { if (!$this->available) { + $location = $cron->class === '' ? $cron->method : $cron->class . '::' . $cron->method; + logger()->error('排程任务只能在协程环境下使用,排程任务 {location} 将不会被执行', ['location' => $location]); return; } $next_run = $cron->expression->getNextRunDate()->getTimestamp();