summaryrefslogtreecommitdiff
path: root/app/Models/LogDAO.php
diff options
context:
space:
mode:
Diffstat (limited to 'app/Models/LogDAO.php')
-rw-r--r--app/Models/LogDAO.php28
1 files changed, 15 insertions, 13 deletions
diff --git a/app/Models/LogDAO.php b/app/Models/LogDAO.php
index 06855ec66..e57e0b1b9 100644
--- a/app/Models/LogDAO.php
+++ b/app/Models/LogDAO.php
@@ -1,21 +1,23 @@
<?php
-class FreshRSS_LogDAO extends Minz_ModelTxt {
- public function __construct () {
- parent::__construct (LOG_PATH . '/application.log', 'r+');
- }
+class FreshRSS_LogDAO {
+ private static $filename = '/application.log';
- public function lister () {
+ public static function lines() {
$logs = array ();
- while (($line = $this->readLine ()) !== false) {
- if (preg_match ('/^\[([^\[]+)\] \[([^\[]+)\] --- (.*)$/', $line, $matches)) {
- $myLog = new FreshRSS_Log ();
- $myLog->_date ($matches[1]);
- $myLog->_level ($matches[2]);
- $myLog->_info ($matches[3]);
- $logs[] = $myLog;
+ $handle = @fopen(LOG_PATH . self::$filename, 'r');
+ if ($handle) {
+ while (($line = fgets($handle)) !== false) {
+ if (preg_match ('/^\[([^\[]+)\] \[([^\[]+)\] --- (.*)$/', $line, $matches)) {
+ $myLog = new FreshRSS_Log ();
+ $myLog->_date ($matches[1]);
+ $myLog->_level ($matches[2]);
+ $myLog->_info ($matches[3]);
+ $logs[] = $myLog;
+ }
}
+ fclose($handle);
}
- return $logs;
+ return array_reverse($logs);
}
}