Create a simple log console

Hi all,

I'm very new to Node-RED and HTML/JS world.
I have my flow which does things and I save some of the results in a log file (append mode).
Now I'd like to show in my dashboard the content of this file every time I write something on it and I'd like to auto scroll the window. This is the code I did so far:

[{"id":"e7cd380a.a4afd","type":"ui_template","z":"88792789.5de198","group":"e2cad6ee.1a36b8","name":"","order":1,"width":0,"height":0,"format":"<script>\nfunction scrollOnLoad(event) {\n const element = event.target;\n element.scrollIntoView({ behavior: 'smooth', block: 'end', inline: 'nearest'});\n}\n</script>","storeOutMessages":true,"fwdInMessages":true,"resendOnRefresh":true,"templateScope":"global","x":420,"y":1040,"wires":[[]]},{"id":"e206f439.99ec4","type":"ui_template","z":"88792789.5de198","group":"e2cad6ee.1a36b8","name":"Log","order":0,"width":"24","height":"7","format":"<div>\n <p ng-style=\"{'margin-bottom':'1em'}\" onLoad=\"scrollOnLoad(event)\">\n {{msg.payload}}\n </p>\n</div>","storeOutMessages":true,"fwdInMessages":true,"resendOnRefresh":true,"templateScope":"local","x":430,"y":1080,"wires":[[]]},{"id":"6d49146e.705d64","type":"tail","z":"88792789.5de198","name":"","filetype":"text","split":"[\\r]{0,1}\\n","filename":"log.txt","inputs":0,"x":310,"y":1080,"wires":[["e206f439.99ec4"]]},{"id":"e2cad6ee.1a36b8","type":"ui_group","z":"","name":"Logger","tab":"4568271d.82b78","order":1,"disp":false,"width":"24","collapse":false},{"id":"4568271d.82b78","type":"ui_tab","z":"","name":"Home","icon":"dashboard","order":1,"disabled":false,"hidden":false}]

It shows only the last line of the file, which is good. But would be great to show not only the last line but append to the p tag and have the history of the prints.

Thanks

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