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

Pass through non-pino lines #95

Merged
merged 5 commits into from
Sep 27, 2016
Merged

Pass through non-pino lines #95

merged 5 commits into from
Sep 27, 2016

Conversation

jsumners
Copy link
Member

Fixes #94

@@ -46,6 +46,13 @@ function filter (value) {
return result
}

function isPinoLine (line) {
var requiredProperties = [ 'time', 'name', 'hostname', 'pid' ]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

time is not required anymore #91 :).
Maybe we should adjust this further.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Duh. I'm the one that removed that.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There has to be a way to determine if the incoming line is a pino line. I have updated it to depend only on hostname and pid properties. They are used to build the (pid on hostname): prefix, which is not conditional as the code currently stands.

return Object.keys(line).filter(function (k) {
return requiredProperties.indexOf(k) > -1
}).length > 0
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we can remove the Object.keys and loop, and just use a couple of conditions with &&. we should also check that v is 0.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have thought about that myself. Before I do it: what do you think of a new common property named pino, like the v property? It could be set to the current version. Then the check only needs to be for the presence of the pino property.

@mcollina
Copy link
Member

I would leave the discussion about "pino" property to another PR/issue. However, I think we should just have a chops thing that also works with bole, bunyan etc.

@@ -46,6 +46,10 @@ function filter (value) {
return result
}

function isPinoLine (line) {
return line.hasOwnProperty('hostname') && line.hasOwnProperty('pid')
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we should check on v to be 0 as well.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If v is even present it's currently at 1.

What I am basing the conditions on is https://github.com/mcollina/pino/blob/master/pretty.js#L100 . Without those properties pretty.js will not construct a valid reformatted log line. The v property is not considered at all for reformatting.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I know but it should :). My bad when writing this for the first time :/.

@mcollina mcollina merged commit 7aef3fe into master Sep 27, 2016
@mcollina mcollina deleted the no-time branch September 27, 2016 20:23
@github-actions
Copy link

github-actions bot commented Feb 9, 2022

This pull request has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Feb 9, 2022
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.

Invalid time value on JSON.stringify()
2 participants