#feature: update log format
This commit is contained in:
@@ -4,6 +4,7 @@ namespace App\Console\Commands;
|
||||
|
||||
use App\Services\ScheduledTaskService;
|
||||
use Illuminate\Console\Command;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
|
||||
class ScheduledTaskRefreshCommand extends Command
|
||||
{
|
||||
@@ -14,26 +15,26 @@ class ScheduledTaskRefreshCommand extends Command
|
||||
public function handle(ScheduledTaskService $taskService): int
|
||||
{
|
||||
try {
|
||||
$this->info('开始刷新定时任务列表...');
|
||||
Log::info('开始刷新定时任务列表...');
|
||||
|
||||
$tasks = $taskService->getAllTasks();
|
||||
|
||||
$this->info(sprintf('成功刷新 %d 个定时任务', count($tasks)));
|
||||
Log::info(sprintf('成功刷新 %d 个定时任务', count($tasks)));
|
||||
|
||||
// 显示任务列表
|
||||
$this->table(
|
||||
['任务名称', '描述', '执行频率', '状态'],
|
||||
array_map(fn($task) => [
|
||||
// 记录任务列表到日志
|
||||
foreach ($tasks as $task) {
|
||||
Log::info(sprintf(
|
||||
' - %s: %s (%s) [%s]',
|
||||
$task['name'],
|
||||
$task['description'],
|
||||
$task['frequency'],
|
||||
$task['enabled'] ? '已启用' : '已禁用',
|
||||
], $tasks)
|
||||
);
|
||||
$task['enabled'] ? '已启用' : '已禁用'
|
||||
));
|
||||
}
|
||||
|
||||
return Command::SUCCESS;
|
||||
} catch (\Exception $e) {
|
||||
$this->error("刷新失败: {$e->getMessage()}");
|
||||
Log::error("刷新失败: {$e->getMessage()}");
|
||||
return Command::FAILURE;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user