diff options
author | Andrey Andreev <narf@devilix.net> | 2016-02-09 20:15:10 +0100 |
---|---|---|
committer | Andrey Andreev <narf@devilix.net> | 2016-02-09 20:15:10 +0100 |
commit | 2342256c076502cbaca86fcff2a1dbbfc49a1900 (patch) | |
tree | 88b0ba297ef0fe42f3e49377b1872258e9f11712 /system/core/Log.php | |
parent | 03c5066137d72868de2fe362879f25472e2fa515 (diff) | |
parent | e9aad049553f4f276093a1a212a2f03f20cb337d (diff) |
Merge pull request #4323 from jspreddy/sai/log_line_formatting_extensibility_change
Refactored CI_Log line formatting to allow extensibility
Diffstat (limited to 'system/core/Log.php')
-rw-r--r-- | system/core/Log.php | 23 |
1 files changed, 20 insertions, 3 deletions
diff --git a/system/core/Log.php b/system/core/Log.php index 72d3cfbae..7c81d358b 100644 --- a/system/core/Log.php +++ b/system/core/Log.php @@ -154,8 +154,8 @@ class CI_Log { * * Generally this function will be called using the global log_message() function * - * @param string the error level: 'error', 'debug' or 'info' - * @param string the error message + * @param string $level The error level: 'error', 'debug' or 'info' + * @param string $msg The error message * @return bool */ public function write_log($level, $msg) @@ -204,7 +204,7 @@ class CI_Log { $date = date($this->_date_fmt); } - $message .= $level.' - '.$date.' --> '.$msg."\n"; + $message .= $this->_format_line($level, $date, $msg); flock($fp, LOCK_EX); @@ -227,4 +227,21 @@ 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 string $level The error level + * @param string $date Formatted date string + * @param string $msg The log message + * @return string Formatted log line with a new line character '\n' at the end + */ + protected function _format_line($level, $date, $message) + { + return $level.' - '.$date.' --> '.$message."\n"; + } } |