summaryrefslogtreecommitdiffstats
path: root/system/core/Log.php
diff options
context:
space:
mode:
authorAndrey Andreev <narf@devilix.net>2015-01-20 11:01:12 +0100
committerAndrey Andreev <narf@devilix.net>2015-01-20 11:01:12 +0100
commit19c6c3d78e62a0d2dcb40b5aff49838fe3fb76ed (patch)
tree8e006ce51cc8a42b2e2b3474cecf9c3ebf63fae2 /system/core/Log.php
parente7068ed2f0459b97346713dc7eb2cd761cb38950 (diff)
parent53e8303f3f38244aaf7c79848f6bf8f01cfb0d95 (diff)
Merge pull request #3427 from gadelat/logdate
Support for microseconds in CI_Log
Diffstat (limited to 'system/core/Log.php')
-rw-r--r--system/core/Log.php15
1 files changed, 14 insertions, 1 deletions
diff --git a/system/core/Log.php b/system/core/Log.php
index 7d318ed57..e7a271f4e 100644
--- a/system/core/Log.php
+++ b/system/core/Log.php
@@ -198,7 +198,20 @@ class CI_Log {
return FALSE;
}
- $message .= $level.' - '.date($this->_date_fmt).' --> '.$msg."\n";
+ // 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.' --> '.$msg."\n";
flock($fp, LOCK_EX);