initial commit
This commit is contained in:
commit
3f64f4a49a
221 files changed
+26665
No files matched your search
@@ -0,0 +1,48 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Rsgrinko\Proton\Console\Commands;
|
||||
|
||||
use Rsgrinko\Proton\Console\Command;
|
||||
use Rsgrinko\Proton\Support\Logger;
|
||||
|
||||
/**
|
||||
* удалить старые логи.
|
||||
*/
|
||||
final class LogsPurgeCommand extends Command
|
||||
{
|
||||
public function name(): string
|
||||
{
|
||||
return 'logs:purge';
|
||||
}
|
||||
|
||||
public function description(): string
|
||||
{
|
||||
return 'удалить логи старше указанного срока';
|
||||
}
|
||||
|
||||
public function usage(): string
|
||||
{
|
||||
return 'logs:purge [--days=30]';
|
||||
}
|
||||
|
||||
public function run(): int
|
||||
{
|
||||
$days = $this->hasOption('days') ? (int) $this->option('days') : null;
|
||||
|
||||
$removed = (new Logger())->purge($days);
|
||||
|
||||
if ($removed === []) {
|
||||
$this->line('Удалять нечего');
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
foreach ($removed as $file) {
|
||||
$this->ok('удалён ' . $file);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user