You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
29 lines
773 B
29 lines
773 B
<?php |
|
|
|
declare(strict_types=1); |
|
|
|
require_once __DIR__ . '/../../vendor/autoload.php'; |
|
|
|
use AutoStore\DiContainer; |
|
use Psr\Log\LoggerInterface; |
|
|
|
$diContainer = new DiContainer(); |
|
$logger = $diContainer->get(LoggerInterface::class); |
|
|
|
try { |
|
// Example log cleanup task |
|
$logFile = $storagePath . '/app.log'; |
|
|
|
if (file_exists($logFile) && filesize($logFile) > 10 * 1024 * 1024) { // 10MB |
|
// Rotate log file |
|
$backupFile = $storagePath . '/app.log.' . date('Y-m-d_H-i-s'); |
|
rename($logFile, $backupFile); |
|
$logger->info("Log file rotated to: {$backupFile}"); |
|
} |
|
|
|
$logger->info('Log cleanup check completed'); |
|
exit(0); |
|
} catch (\Exception $e) { |
|
$logger->error('Error during log cleanup: ' . $e->getMessage()); |
|
exit(1); |
|
} |