seek(PHP_INT_MAX); $total_lines = $file->key() + 1; $start_line = max(0, $total_lines - $lines); $file->seek($start_line); $content = ''; while (!$file->eof()) { $content .= $file->fgets(); } return $content; } /** * Clear log file */ public static function clear_log($log_file = 'publish-sync') { if (self::$log_dir === null) { self::init(); } $file_path = self::$log_dir . '/' . $log_file . '.log'; if (file_exists($file_path)) { @unlink($file_path); } } /** * Get all log files */ public static function get_log_files() { if (self::$log_dir === null) { self::init(); } if (!is_dir(self::$log_dir)) { return array(); } $files = glob(self::$log_dir . '/*.log'); $log_files = array(); foreach ($files as $file) { $log_files[] = array( 'name' => basename($file, '.log'), 'path' => $file, 'size' => filesize($file), 'modified' => filemtime($file), ); } return $log_files; } } // Initialize logger Igny8_Logger::init();