summaryrefslogtreecommitdiffstats
path: root/system/core/Log.php
diff options
context:
space:
mode:
authorGabriel Potkány <gadelat@gmail.com>2014-12-20 00:00:23 +0100
committerGabriel Potkány <gadelat@gmail.com>2014-12-20 00:00:23 +0100
commit53e8303f3f38244aaf7c79848f6bf8f01cfb0d95 (patch)
tree63e4cb6a42151bf3ab507c28d1cb8473a3549da9 /system/core/Log.php
parent9c00ab0ec2c9d909c025bd5dbd34da70bdcb0422 (diff)
Make µs support conditional and fix style
Diffstat (limited to 'system/core/Log.php')
-rw-r--r--system/core/Log.php18
1 files changed, 13 insertions, 5 deletions
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);