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

Timestamp is incorrect when milliseconds < 100 #156

Open
bmaupin opened this issue Sep 30, 2021 · 0 comments · May be fixed by #157
Open

Timestamp is incorrect when milliseconds < 100 #156

bmaupin opened this issue Sep 30, 2021 · 0 comments · May be fixed by #157

Comments

@bmaupin
Copy link

bmaupin commented Sep 30, 2021

There's a bug which only occurs when milliseconds are less than 100:

<131>1 2021-09-27T15:52:34.137-07:00 localhost test-graylog-syslog 103039 - - error: Test error message, without stack trace
<131>1 2021-09-27T15:52:35.35-07:00 localhost test-graylog-syslog 103065 - - error: Test error message, without stack trace

15:52:35.35 should be 15:52:35.035. As-is it will probably get interpreted as 15:52:35.350 (I know Graylog does this, for instance).

Interestingly enough, this bug is mentioned directly in the RFC5424 spec:

The TIMESTAMP described in Section 6.2.3 supports fractional seconds.
This provides grounds for a very common coding error, where leading
zeros are removed from the fractional seconds. For example, the
TIMESTAMP "2003-10-11T22:13:14.003" may be erroneously written as
"2003-10-11T22:13:14.3". This would indicate 300 milliseconds
instead of the 3 milliseconds actually meant.

(https://datatracker.ietf.org/doc/html/rfc5424#appendix-A.4)

This is a bug in the glossy dependency. The one used by this library hasn't been updated since 2016 and hasn't seen a release since 2014. However, there's a fork that includes a fix for this as well as at least one other issue (#139):

https://www.npmjs.com/package/@myndzi/glossy

bmaupin added a commit to bmaupin/winston-syslog that referenced this issue Sep 30, 2021
- Use the correct time zone (fixes winstonjs#138)
- Fix formatting for milliseconds (fixes winstonjs#156)
- Add tests
bmaupin added a commit to bmaupin/winston-syslog that referenced this issue Sep 30, 2021
- Use the correct time zone (fixes winstonjs#139)
- Fix formatting for milliseconds (fixes winstonjs#156)
- Add tests
@bmaupin bmaupin linked a pull request Sep 30, 2021 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant