Getting log levels from journalctl?

I'd like a custom logger that can prepend priority flags to systemd

i.e. if console.error("fubar")

I want to output:

<3>fubar

And so on for .debug, .warn, .info ... etc.

Has this been done? thanks

You can create your own custom logger in settings.js - see Logging : Node-RED

Have you got an example of using this that supports different handlers for different priorities or does the priority get passed in? All the examples of it I've seen seem to override a single priority.

Ok. I crafted a custom logger, set it to trace, and sure enough I get the levels for the native nodered events.

For example:
{
level: 60,
msg: 'Stopped node ui_switch:5e963078.ac897 (232ms)',
timestamp: 1616181045174
}

However, for individual function nodes that call:
console.error
or
console.warn

The log goes straight out to stdout using whatever default priority is in the service - there's no interception!

Try calling node.error etc instead

Yes - using console.log etc bypasses the Node-RED logging framework and gets written straight to stdout regardless of how you have the loggers configured.

Thanks Nick,

I'll override with a hander in global. Something like:

const _console ={
_combine : function(a) {
return Array.prototype.join.call(a);
},
log :function(){
console.log(this._combine(arguments));
},
error :function(){
console.log("<3>",this._combine(arguments));
},
}

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