Merge pull request #3427 from gadelat/logdate

Support for microseconds in CI_Log
diff --git a/system/core/Log.php b/system/core/Log.php
index 7d318ed..e7a271f 100644
--- a/system/core/Log.php
+++ b/system/core/Log.php
@@ -198,7 +198,20 @@
 			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);
 
diff --git a/user_guide_src/source/changelog.rst b/user_guide_src/source/changelog.rst
index 7211210..73a183b 100644
--- a/user_guide_src/source/changelog.rst
+++ b/user_guide_src/source/changelog.rst
@@ -553,6 +553,7 @@
 
       -  Added a ``$config['log_file_permissions']`` setting.
       -  Changed the library constructor to try to create the **log_path** directory if it doesn't exist.
+      -  Added support for microseconds ("u" date format character) in ``$config['log_date_format']``.
 
    -  Added `compatibility layers <general/compatibility_functions>` for: