diff --git a/app/common/Implement/Log/MySQLHandler.php b/app/common/Implement/Log/MySQLHandler.php index cae0ac6..d7b03f0 100644 --- a/app/common/Implement/Log/MySQLHandler.php +++ b/app/common/Implement/Log/MySQLHandler.php @@ -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); } }