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:16:29 +0100 |
commit | 1ccc8bed6ed169356ef31397d9ae988a16cd9a63 (patch) | |
tree | dc6751d85654480a0d242f2cc26d77465af1b4c2 /system | |
parent | aec5126f5d554fb3b14cd8f37adf57339446d957 (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')
-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"; + } } |