Skip to content
This repository has been archived by the owner on Feb 1, 2022. It is now read-only.

fix: Pad milliseconds with three zeroes #1

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

bmaupin
Copy link

@bmaupin bmaupin commented Sep 28, 2021

Hi!

This fork appears to have inherited a bug from upstream. As this seems to be the best-maintained fork of glossy, I'm submitting this PR to fix this issue but also in hopes that you might be interested in publishing this to NPM for others to use 😀

The bug is that milliseconds are padded only with two zeroes, e.g.

<131>1 2021-09-27T15:52:35.35-07:00 localhost test-graylog-syslog 103065 - - error: Test message

Some logging platforms (like Graylog, not sure about logdna) parse 15:52:35.35 as 15:52:35.350 instead of 15:52:35.035, so this fixes that.

Here's a related issue with more details: winstonjs/winston-syslog#139

Thanks!

It was previously padded only with two zeroes, which Graylog parses incorrectly
@bmaupin
Copy link
Author

bmaupin commented Sep 28, 2021

I also just ran across this in the spec in case there's any doubt about this being a bug:

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)

Thanks!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant