writeLine('Starting log rotation...'); // Standard Log-Pfade $logPaths = $this->getLogPaths(); $rotator = LogRotator::production(); $rotatedCount = 0; $totalSize = Byte::zero(); foreach ($logPaths as $name => $path) { if (! file_exists($path)) { $output->writeLine("Skipping {$name}: File not found ({$path})"); continue; } $beforeSize = Byte::fromBytes(filesize($path)); $totalSize = $totalSize->add($beforeSize); if ($rotator->shouldRotate($path)) { $output->writeLine("Rotating {$name} ({$path})"); if ($rotator->rotateLog($path)) { $rotatedCount++; $output->writeLine(" ✓ Successfully rotated {$name}"); // Zeige Rotation-Info $info = $rotator->getRotationInfo($path); $output->writeLine(" Current size: {$info['current_size']}"); $output->writeLine(" Rotated files: " . count($info['rotated_files'])); } else { $output->writeLine(" ✗ Failed to rotate {$name}"); } } else { $output->writeLine(" → {$name} doesn't need rotation"); $info = $rotator->getRotationInfo($path); $output->writeLine(" Current size: {$info['current_size']} / {$info['max_size']}"); } } $output->writeLine(''); $output->writeLine("Rotation completed:"); $output->writeLine(" Files rotated: {$rotatedCount}"); $output->writeLine(" Total log size: " . $totalSize->toHumanReadable()); return ExitCode::SUCCESS; } private function getLogPaths(): array { $basePath = $_SERVER['DOCUMENT_ROOT'] ?? '/var/www/html'; return [ 'app' => $basePath . '/public/logs/app.log', 'mcp_debug' => $basePath . '/mcp_debug.log', 'framework' => '/tmp/framework.log', ]; } }