FlowFuse / device-agent

An agent to run FlowFuse managed instances of Node-RED on devices
Apache License 2.0
16 stars 8 forks source link

Use of console.log in Function node can break device log streaming #218

Closed knolleary closed 10 months ago

knolleary commented 10 months ago

Current Behavior

A Function node can use console.log to write directly to stdout. This can break the log parsing to stops logs being streamed to the platform.

Expected Behavior

console.log not to break the logs

Steps To Reproduce

Add console.log to a Function node running on a device

Environment

hardillb commented 10 months ago

This is specifically console.log outputing a JSON object, a normal string works fine

hardillb commented 10 months ago

Problem is here:

https://github.com/FlowFuse/device-agent/blob/be492a783f267062aa7ce25641ef34c12983506e/lib/logging/log.js#L20-L26

Where we just try and JSON parse the line (as we are using the custom logger plug in to output JSON), so we need to check if the input is actually from the NR logger or from something else.

Steve-Mcl commented 10 months ago

Verified from local device to staging

Image

Image