LogDAO.php 566 B

1234567891011121314151617181920212223
  1. <?php
  2. class FreshRSS_LogDAO {
  3. private static $filename = '/application.log';
  4. public static function lines() {
  5. $logs = array ();
  6. $handle = @fopen(LOG_PATH . self::$filename, 'r');
  7. if ($handle) {
  8. while (($line = fgets($handle)) !== false) {
  9. if (preg_match ('/^\[([^\[]+)\] \[([^\[]+)\] --- (.*)$/', $line, $matches)) {
  10. $myLog = new FreshRSS_Log ();
  11. $myLog->_date ($matches[1]);
  12. $myLog->_level ($matches[2]);
  13. $myLog->_info ($matches[3]);
  14. $logs[] = $myLog;
  15. }
  16. }
  17. fclose($handle);
  18. }
  19. return array_reverse($logs);
  20. }
  21. }