aboutsummaryrefslogtreecommitdiff
path: root/app/models/Log_Model.php
diff options
context:
space:
mode:
authorGravatar Alexandre Alapetite <alexandre@alapetite.fr> 2013-11-13 22:47:26 +0100
committerGravatar Alexandre Alapetite <alexandre@alapetite.fr> 2013-11-13 22:47:26 +0100
commit803cd05a58c93b91dc73db32fd95cc11372aa82f (patch)
tree64930cd733b640acc980625835145ecd7e3d4bb1 /app/models/Log_Model.php
parentbff31a6d5ec76ebb1ef724a281cc7318991fc11e (diff)
Amélioration vitesse lecture des logs
Diffstat (limited to 'app/models/Log_Model.php')
-rw-r--r--app/models/Log_Model.php17
1 files changed, 8 insertions, 9 deletions
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