summaryrefslogtreecommitdiffstats
path: root/system
diff options
context:
space:
mode:
authorSai Phaninder Reddy Jonnala <sai.jonnala@gopassport.com>2015-12-21 17:33:57 +0100
committerSai Phaninder Reddy Jonnala <sai.jonnala@gopassport.com>2015-12-21 17:37:30 +0100
commitdb68d401f67496ba5e495dd36adabe6d85187b44 (patch)
tree963f059aac371a7ab2add684cd7319ebba846f8f /system
parent78b151646f4fb684c0328a67cb2a9bed3e1d8f3f (diff)
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.
Diffstat (limited to 'system')
-rw-r--r--system/core/Log.php18
1 files changed, 17 insertions, 1 deletions
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";
+ }
}