From db68d401f67496ba5e495dd36adabe6d85187b44 Mon Sep 17 00:00:00 2001 From: Sai Phaninder Reddy Jonnala Date: Mon, 21 Dec 2015 11:33:57 -0500 Subject: Refactoring the `CI_Log` line formatting - Extracting the `CI_Log` line formatting into a protected function `_format_log_line()` so as to make it easy to change the log line format via extending the class and overriding the method. --- system/core/Log.php | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) (limited to 'system/core') diff --git a/system/core/Log.php b/system/core/Log.php index e8cb401f5..cf2793a56 100644 --- a/system/core/Log.php +++ b/system/core/Log.php @@ -204,7 +204,7 @@ class CI_Log { $date = date($this->_date_fmt); } - $message .= $level.' - '.$date.' --> '.$msg."\n"; + $message .= $this->_format_log_line($level, $date, $msg); flock($fp, LOCK_EX); @@ -227,4 +227,20 @@ class CI_Log { return is_int($result); } + /** + * Format the log line. + * + * This is for extensibility of log formatting. + * If you want to change the log format, + * extend the CI_Log class and override this method. + * + * @param $level + * @param $date + * @param $msg + * + * @return string formatted log line with a new line character '\n' at the end. + */ + protected function _format_log_line($level, $date, $msg){ + return $level.' - '.$date.' --> '.$msg."\n"; + } } -- cgit v1.2.3-24-g4f1b