_log_path.'log-'.date('Y-m-d').'.php'; if ( ! file_exists($filepath)) { return false; } else { return $filepath; } } /** * * @return the current size of the log file */ public function log_file_size () { clearstatcache(); return filesize ($this->log_file()); } /** * Return the last lines that match a pattern in the log * @param unknown $pattern * @param $level = "DEBUG" | "INFO" | "ERROR" */ public function last_lines ($pattern = "", $level = "") { $log = file_get_contents($this->log_file()); $lines = explode("\n", $log); $matching = preg_grep("/{$pattern}/", $lines); if ($level != "") { $matching = preg_grep("/^{$level}/", $matching); } return $matching; } /** * Return the last lines that match a pattern in the log * @param unknown $pattern * @param $level = "DEBUG" | "INFO" | "ERROR" */ public function count_lines ($pattern = "", $level = "") { return count($this->last_lines($pattern, $level)); } } // END Log Class /* End of file MY_Log.php */ /* Location: ./application/libraries/MY_Log.php */