File tree Expand file tree Collapse file tree 2 files changed +15
-1
lines changed
Expand file tree Collapse file tree 2 files changed +15
-1
lines changed Original file line number Diff line number Diff line change @@ -198,7 +198,20 @@ public function write_log($level, $msg)
198198 return FALSE ;
199199 }
200200
201- $ message .= $ level .' - ' .date ($ this ->_date_fmt ).' --> ' .$ msg ."\n" ;
201+ // Instantiating DateTime with microseconds appended to initial date is needed for proper support of this format
202+ if (strpos ($ this ->_date_fmt , 'u ' ) !== FALSE )
203+ {
204+ $ microtime_full = microtime (TRUE );
205+ $ microtime_short = sprintf ("%06d " , ($ microtime_full - floor ($ microtime_full )) * 1000000 );
206+ $ date = new DateTime (date ('Y-m-d H:i:s. ' .$ microtime_short , $ microtime_full ));
207+ $ date = $ date ->format ($ this ->_date_fmt );
208+ }
209+ else
210+ {
211+ $ date = date ($ this ->_date_fmt );
212+ }
213+
214+ $ message .= $ level .' - ' .$ date .' --> ' .$ msg ."\n" ;
202215
203216 flock ($ fp , LOCK_EX );
204217
Original file line number Diff line number Diff line change @@ -553,6 +553,7 @@ Release Date: Not Released
553553
554554 - Added a ``$config['log_file_permissions'] `` setting.
555555 - Changed the library constructor to try to create the **log_path ** directory if it doesn't exist.
556+ - Added support for microseconds ("u" date format character) in ``$config['log_date_format'] ``.
556557
557558 - Added `compatibility layers <general/compatibility_functions> ` for:
558559
You can’t perform that action at this time.
0 commit comments