Debug Messages to a Dashboard iFrame

Hi All,

I am trying to display debug messages on a Dashboard - Is it possible?

Using the below, I can get the frame and basics displayed, but, alas, no actual messages:

[
    {
        "id": "31afcce42af39fc2",
        "type": "ui_iframe",
        "z": "3055fb7f.f62864",
        "g": "d141fc64606339f2",
        "group": "e8557d5f4c6de4f3",
        "name": "Debug Messages",
        "order": 1,
        "width": "7",
        "height": "5",
        "url": "http://127.0.0.1:1880/debug/view/view.html",
        "origin": "*",
        "scale": "100",
        "x": 410,
        "y": 2020,
        "wires": [
            []
        ]
    },
    {
        "id": "e8557d5f4c6de4f3",
        "type": "ui_group",
        "name": "Debug Messages",
        "tab": "ac8a95bb.741908",
        "order": 9,
        "disp": true,
        "width": "7",
        "collapse": true,
        "className": ""
    },
    {
        "id": "ac8a95bb.741908",
        "type": "ui_tab",
        "name": "Management & Diag",
        "icon": "dashboard",
        "order": 13,
        "disabled": false,
        "hidden": false
    }
]

Any idea if I am just chasing a dream?

Regds
Ed

It is possible and I think that I put an example flow in the flows library years ago.

Hey J!

Was it this one: Display Node-Red Log Output using Dashboard 2

Regds
Ed

Looks like it - 6 years ago! Wonder if it still works :smiley:

I've also done custom logging with uibuilder. The latest of which uses a custom node-red logger that uses the MQTT client library to push log entries to an MQTT topic. There is a flow that listens for that topic and sends the data to a uibuilder node (could be something in Dashboard instead I expect).

Snippet from settings.js

    /** Configure the logging output */
    logging: {
        console: {
            /** Level of logging to be recorded. Options are:
             * fatal - only those errors which make the application unusable should be recorded
             * error - record errors which are deemed fatal for a particular request + fatal errors
             * warn - record problems which are non fatal + errors + fatal errors
             * info - record information about the general running of the application + warn + error + fatal errors
             * debug - record information which is more verbose than info + info + warn + error + fatal errors
             * trace - record very detailed logging + debug + info + warn + error + fatal errors
             * off - turn off all logging (doesn't affect metrics or audit)
             */
            level: 'info',
            /** Whether or not to include metric events in the log output */
            metrics: false,
            /** Whether or not to include audit events in the log output */
            audit: false,
        },
        mqttLog: {
            level: 'trace',
            metrics: false,
            audit: false,
            handler: function(settings) {
                const nrLogLevels = {
                    10: 'FATAL', 20: 'ERROR', 30: 'WARN ', 40: 'INFO ', 50: 'DEBUG', 60: 'TRACE', 98: 'AUDIT', 99: 'MTRIC'
                }
                const myCustomLevels = {
                    levels: {
                        'FATAL':10, 
                        'ERROR':20, 
                        'WARN ':30, 
                        'INFO ':40, 
                        'DEBUG':50, 
                        'TRACE':60, 
                        'AUDIT':98, 
                        'MTRIC':99
                    },
                    colors: {
                        'FATAL':'redBG', 
                        'ERROR':'red', 
                        'WARN ':'orange', 
                        'INFO ':'yellow', 
                        'DEBUG':'green', 
                        'TRACE':'cyan', 
                        'AUDIT':'grey', 
                        'MTRIC':'grey'
                    } 
                }

                const mqtt = require('mqtt')
                const client  = mqtt.connect('mqtt://home.knightnet.co.uk')

                return function(msg) {
                    if ( msg.level < 51 || msg.msg.includes('[uibuilder') || msg.msg.startsWith('+-') || msg.msg.startsWith('| ') || msg.msg.startsWith('>>') ) {
                        client.publish( 'nrlog/dev', JSON.stringify(msg) )
                    }
                }
            }
        },
    },
1 Like

Hey J!

I took a read through your flow... My limited understanding tells me that it will "capture" the required data from the system, then filter it, then array it, then do plenty of clever stuff to use the data...

A little "Too Advanced" for what I am looking for...(Read that possibly as "Capable of)...

I am looking for a much simpler solution - maybe I am being lazy, maybe a bit too simplistic...

Literally a case of displaying the "Log Window" in a separate browser page, a la when you click on this (Bottom RHS of the Debug Window):

screenshot-192.168.0.118_1880-2022.08.09-11_04_25

And get a separate browser pop up of this:

Maybe I am being a little too simplistic in my requirements....

There is an additional need for this too, beyond adding it to a dashboard... I would like to be able to view the log output directly, sans dashboards etc under particular circumstances on remote machines etc...

Holding thumbs!!

Regds
Ed

I think you have some learning ahead of you :slight_smile:

Because Node-RED is a general-purpose development environment, you can do just about anything. Getting log data into a separate output is possible in several ways.

The actual log can be viewed in a terminal window for example. And my last post is an example of doing custom logging (in that case, it shows priority log entries but shows all - including detailed trace logs - for uibuilder. It sends each log entry to an MQTT topic to make it easy to consume in Node-RED flows, I just send it to a web page that I happen to use uibuilder for but it could be something else).

There is also a custom log node which lets you do all sorts of things.

The thing about the node-red logs is that they may contain sensitive information. So outputting to a web page is, of necessity, something that needs to be considered carefully. There isn't a one-size-fits-all other than the debug panel and the debug window from the node-red Editor that you've already seen.

Yep.... Every day....

Agreed 100% !! (Although in this case, the system only has to protect itself from me.... No other users/abusers/fingers get into it.... The tech level of the rest of the household is "Fear/Ignorance" based - Don't understand it, not willing try to understand it, stay away from it....)

(Point in case: "We are out of water.... Have you checked if the tank is empty? .... How do I do that? ..... And it snowballs from there....)

I digress.... mutter mutter.... swear ... curse...

Any pointers on how to open a separate, independent, unsecured, debug window easily? (Aware of the risks, I am...)

Regds
E

1 Like

Simplest method is to open an SSH terminal window onto the server (I'm assuming you are running on Linux) and access the logs directly. If you are running via Dave's Rasbian/Debian install script, you can do something like sudo journalctl --unit=nodered --follow --lines=500 --no-hostname --output=cat

The command man journalctl will give you info on the parameters.