Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ISO 8601 log format #2

Open
2 tasks done
weierophinney opened this issue Dec 31, 2019 · 1 comment
Open
2 tasks done

ISO 8601 log format #2

weierophinney opened this issue Dec 31, 2019 · 1 comment
Labels
Enhancement New feature or request Help Wanted

Comments

@weierophinney
Copy link
Contributor

  • 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.

 'zend-expressive-swoole' => [
        'swoole-http-server' => [
            'logger' => [
                'format' => '%{%FT%T%z}t',
            ],
    ]
]

Suggestion 1

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.


Originally posted by @marc-mabe at zendframework/zend-expressive-swoole#62

@weierophinney
Copy link
Contributor Author

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.


Originally posted by @marc-mabe at zendframework/zend-expressive-swoole#62 (comment)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Enhancement New feature or request Help Wanted
Projects
None yet
Development

No branches or pull requests

1 participant