You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I was not able to find an open or closed issue matching what I'm seeing.
This is not a question. (Questions should be asked on chat (Signup here) or our forums.)
Currently it's impossible to define an own date format in the logger.
The problem goes down to the usage of strftime which uses % for formating times as well as the other non common date formats.
Code to reproduce the issue
To log times in ISO 8601 format, according to the documentation this would look like the following.
But as % is used already to parse the log format the formatter just generates useless output.
My recommended suggestion would to to use the more common date format instead of strftime because, yea it's more common in PHP as it's the same as in DateTime and it does not use % to it's much more readable and much simpler to parse.
Suggestion 2
Another suggestion would be to "fix" the log formatter and combine replaceConstantDirectives and replaceVariableDirectives on parsing to make sure %{format}t gets used by the variable directives no matter how the format looks like.
OK there is a workaround but it's still super hard to create a useful output as well as read the format to understand what's going on.
%{%%FT%%T%%z}t This basically escapes the % character of the format and works but as I sad it's super hard to read/write and also it's not performant as it needs to replace the characters multiple times.
Currently it's impossible to define an own date format in the logger.
The problem goes down to the usage of
strftime
which uses%
for formating times as well as the other non common date formats.Code to reproduce the issue
To log times in ISO 8601 format, according to the documentation this would look like the following.
But as
%
is used already to parse the log format the formatter just generates useless output.Suggestion 1
My recommended suggestion would to to use the more common
date
format instead ofstrftime
because, yea it's more common in PHP as it's the same as inDateTime
and it does not use%
to it's much more readable and much simpler to parse.Suggestion 2
Another suggestion would be to "fix" the log formatter and combine
replaceConstantDirectives
andreplaceVariableDirectives
on parsing to make sure%{format}t
gets used by the variable directives no matter how the format looks like.Originally posted by @marc-mabe at zendframework/zend-expressive-swoole#62
The text was updated successfully, but these errors were encountered: