From 803cd05a58c93b91dc73db32fd95cc11372aa82f Mon Sep 17 00:00:00 2001 From: Alexandre Alapetite Date: Wed, 13 Nov 2013 22:47:26 +0100 Subject: Amélioration vitesse lecture des logs MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/models/Log_Model.php | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) (limited to 'app/models/Log_Model.php') diff --git a/app/models/Log_Model.php b/app/models/Log_Model.php index 5c280fa7a..988996c9d 100644 --- a/app/models/Log_Model.php +++ b/app/models/Log_Model.php @@ -29,19 +29,18 @@ class LogDAO extends Model_txt { public function __construct () { parent::__construct (LOG_PATH . '/application.log', 'r+'); } - + public function lister () { $logs = array (); - - $i = 0; while (($line = $this->readLine ()) !== false) { - $logs[$i] = new Log_Model (); - $logs[$i]->_date (preg_replace ("'\[(.*?)\] \[(.*?)\] --- (.*?)'U", "\\1", $line)); - $logs[$i]->_level (preg_replace ("'\[(.*?)\] \[(.*?)\] --- (.*?)'U", "\\2", $line)); - $logs[$i]->_info (preg_replace ("'\[(.*?)\] \[(.*?)\] --- (.*?)'U", "\\3", $line)); - $i++; + if (preg_match ('/^\[([^\[]+)\] \[([^\[]+)\] --- (.*)$/', $line, $matches)) { + $myLog = new Log_Model (); + $myLog->_date ($matches[1]); + $myLog->_level ($matches[2]); + $myLog->_info ($matches[3]); + $logs[] = $myLog; + } } - return $logs; } } \ No newline at end of file -- cgit v1.2.3