Error log format

I run node-red using pm2 and the errors are logged to .pm2/logs/node-red-error.log

For example:

(node:10660) DeprecationWarning: PG.connect is deprecated - please see the upgrade guide at https://node-postgres.com/guides/upgrading

Question 1: Is there a way to add a timestamp or better a date and time to the entries?

Question 2 : if I do grep 10660 .node-red/* nothing is returned, where is this node defined?

Node-RED already includes a timestamp. Partial output of pm2 logs:

That warning had been logged by some piece of node.js code. It has been written directly to stdout of the node process, bypassing the Node-RED logging framework. That is why it looks "different" to normal NR log output.

The fact it mentions postgres should be the biggest clue for where it is coming from. What postgres node have you got installed? The message won't be coming from the NR node, but from the underlying postgres library module it is using.

Thanks for your reply @TotallyInformation , unfortunately there is no timestamp for the error log

/home/nodered/.pm2/logs/node-red-error.log last 15 lines:
0|node-red | (node:25266) DeprecationWarning: PG.connect is deprecated - please see the upgrade guide at https://node-postgres.com/guides/upgrading
0|node-red | (node:21253) DeprecationWarning: PG.connect is deprecated - please see the upgrade guide at https://node-postgres.com/guides/upgrading
0|node-red | (node:9248) DeprecationWarning: PG.connect is deprecated - please see the upgrade guide at https://node-postgres.com/guides/upgrading

I only see it for the out log:

/home/nodered/.pm2/logs/node-red-out.log last 15 lines:
0|node-red | 18 Feb 10:22:55 - [metric] {"level":99,"nodeid":"6c78f7cb.7c424","event":"node.json.send","msgid":"791ef036.27395","timestamp":1582017775148}

Hi @knolleary,

Thank you for your reply. Do you mean that node-red error.log reports errors and warnings from node.js? And this happens via pm2 in my case, bypassing node-red?

The warning I reported was just an example, the really important error is the following:

You have triggered an unhandledRejection, you may have forgotten to catch a Promise rejection:
Error: Connection refused: Not authorized
    at MqttClient._handleConnack (/home/nodered/.node-red/node_modules/mqtt/lib/client.js:920:15)
    at MqttClient._handlePacket (/home/nodered/.node-red/node_modules/mqtt/lib/client.js:350:12)
    at work (/home/nodered/.node-red/node_modules/mqtt/lib/client.js:292:12)
    at Writable.writable._write (/home/nodered/.node-red/node_modules/mqtt/lib/client.js:302:5)
    at doWrite (/home/nodered/.node-red/node_modules/readable-stream/lib/_stream_writable.js:428:64)
    at writeOrBuffer (/home/nodered/.node-red/node_modules/readable-stream/lib/_stream_writable.js:417:5)
    at Writable.write (/home/nodered/.node-red/node_modules/readable-stream/lib/_stream_writable.js:334:11)
    at Socket.ondata (_stream_readable.js:705:22)
    at Socket.emit (events.js:193:13)
    at Socket.EventEmitter.emit (domain.js:481:20)
(node:24363) UnhandledPromiseRejectionWarning: Error: Connection refused: Not authorized
    at MqttClient._handleConnack (/home/nodered/.node-red/node_modules/mqtt/lib/client.js:920:15)
    at MqttClient._handlePacket (/home/nodered/.node-red/node_modules/mqtt/lib/client.js:350:12)
    at work (/home/nodered/.node-red/node_modules/mqtt/lib/client.js:292:12)
    at Writable.writable._write (/home/nodered/.node-red/node_modules/mqtt/lib/client.js:302:5)
    at doWrite (/home/nodered/.node-red/node_modules/readable-stream/lib/_stream_writable.js:428:64)
    at writeOrBuffer (/home/nodered/.node-red/node_modules/readable-stream/lib/_stream_writable.js:417:5)
    at Writable.write (/home/nodered/.node-red/node_modules/readable-stream/lib/_stream_writable.js:334:11)
    at Socket.ondata (_stream_readable.js:705:22)
    at Socket.emit (events.js:193:13)
    at Socket.EventEmitter.emit (domain.js:481:20)

So this also comes from Node?

Thanks,
Stefano

Yes, that has come directly from the node.js runtime and indicates a bug with a node - possibly the Mqtt nodes.

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.