Mysql log retain
This commit is contained in:
@ -12,7 +12,7 @@ class MySQLHandler extends AbstractProcessingHandler
|
||||
private bool $initialized = false;
|
||||
private PDOStatement $statement;
|
||||
|
||||
public function __construct(protected Connection $connection, int|string|Level $level = Level::Debug, bool $bubble = true)
|
||||
public function __construct(protected Connection $connection, protected int $retainDays = 90, int|string|Level $level = Level::Debug, bool $bubble = true)
|
||||
{
|
||||
parent::__construct($level, $bubble);
|
||||
}
|
||||
@ -54,7 +54,7 @@ QUERY;
|
||||
}
|
||||
private function cleanup(): void
|
||||
{
|
||||
$query = "DELETE FROM monolog WHERE time < DATE_SUB(CURDATE(), INTERVAL 90 DAY)";
|
||||
$query = "DELETE FROM monolog WHERE time < DATE_SUB(CURDATE(), INTERVAL {$this->retainDays} DAY)";
|
||||
$this->connection->query($query);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user