From f83262eceefb37053a8a025fefff0cbb03985f2f Mon Sep 17 00:00:00 2001 From: Gabriel Potkány Date: Fri, 19 Dec 2014 12:35:00 +0100 Subject: Support for microseconds --- system/core/Log.php | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'system/core/Log.php') diff --git a/system/core/Log.php b/system/core/Log.php index b0576c58f..ab8ae2857 100644 --- a/system/core/Log.php +++ b/system/core/Log.php @@ -198,7 +198,12 @@ class CI_Log { return FALSE; } - $message .= $level.' - '.date($this->_date_fmt).' --> '.$msg."\n"; + // Instantiate DateTime with microseconds accuracy to allow proper use of "u" character in date format + $t = microtime(true); + $micro = sprintf("%06d",($t - floor($t)) * 1000000); + $date = new DateTime(date('Y-m-d H:i:s.'.$micro, $t)); + + $message .= $level.' - '.$date->format($this->_date_fmt).' --> '.$msg."\n"; flock($fp, LOCK_EX); -- cgit v1.2.3-24-g4f1b From 53e8303f3f38244aaf7c79848f6bf8f01cfb0d95 Mon Sep 17 00:00:00 2001 From: Gabriel Potkány Date: Sat, 20 Dec 2014 00:00:23 +0100 Subject: Make µs support conditional and fix style MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- system/core/Log.php | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) (limited to 'system/core/Log.php') diff --git a/system/core/Log.php b/system/core/Log.php index ab8ae2857..ccaaf4b9a 100644 --- a/system/core/Log.php +++ b/system/core/Log.php @@ -198,12 +198,20 @@ class CI_Log { return FALSE; } - // Instantiate DateTime with microseconds accuracy to allow proper use of "u" character in date format - $t = microtime(true); - $micro = sprintf("%06d",($t - floor($t)) * 1000000); - $date = new DateTime(date('Y-m-d H:i:s.'.$micro, $t)); + // Instantiating DateTime with microseconds appended to initial date is needed for proper support of this format + if (strpos($this->_date_fmt, 'u') !== FALSE) + { + $microtime_full = microtime(TRUE); + $microtime_short = sprintf("%06d", ($microtime_full - floor($microtime_full)) * 1000000); + $date = new DateTime(date('Y-m-d H:i:s.'.$microtime_short, $microtime_full)); + $date = $date->format($this->_date_fmt); + } + else + { + $date = date($this->_date_fmt); + } - $message .= $level.' - '.$date->format($this->_date_fmt).' --> '.$msg."\n"; + $message .= $level.' - '.$date.' --> '.$msg."\n"; flock($fp, LOCK_EX); -- cgit v1.2.3-24-g4f1b From 4cbe463b4c442e0e2dae2f43565e77f7ac5ecb86 Mon Sep 17 00:00:00 2001 From: vlakoff Date: Wed, 21 Jan 2015 22:56:22 +0100 Subject: Remove closing blocks at end of PHP files --- system/core/Log.php | 3 --- 1 file changed, 3 deletions(-) (limited to 'system/core/Log.php') diff --git a/system/core/Log.php b/system/core/Log.php index e7a271f4e..833316273 100644 --- a/system/core/Log.php +++ b/system/core/Log.php @@ -235,6 +235,3 @@ class CI_Log { } } - -/* End of file Log.php */ -/* Location: ./system/core/Log.php */ \ No newline at end of file -- cgit v1.2.3-24-g4f1b