From 27e88761e02db80a7075f9e3d8e245b17b9b8ccf Mon Sep 17 00:00:00 2001 From: Juan Pablo Vial Date: Fri, 7 Jun 2024 17:18:20 -0400 Subject: [PATCH] Mysql log retain --- app/common/Implement/Log/MySQLHandler.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) 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); } }