mirror of
https://github.com/node-red/node-red.git
synced 2025-03-01 10:36:34 +00:00
Add event log to editor
Shows output from git pull/push and npm install in the editor
This commit is contained in:
@@ -42,6 +42,21 @@ function handleRuntimeEvent(event) {
|
||||
runtime.log.trace("runtime event: "+JSON.stringify(event));
|
||||
publish("notification/"+event.id,event.payload||{},event.retain);
|
||||
}
|
||||
function handleEventLog(event) {
|
||||
var type = event.payload.type;
|
||||
var id = event.id;
|
||||
if (event.payload.data) {
|
||||
var data = event.payload.data;
|
||||
if (data.endsWith('\n')) {
|
||||
data = data.substring(0,data.length-1);
|
||||
}
|
||||
var lines = data.split(/\n/);
|
||||
lines.forEach(line => {
|
||||
runtime.log.debug((type?("["+type+"] "):"")+line)
|
||||
})
|
||||
}
|
||||
publish("event-log/"+event.id,event.payload||{});
|
||||
}
|
||||
|
||||
function publish(topic,data,retain) {
|
||||
if (retain) {
|
||||
@@ -64,6 +79,8 @@ var api = module.exports = {
|
||||
runtime.events.on("runtime-event",handleRuntimeEvent);
|
||||
runtime.events.removeListener("comms",handleCommsEvent);
|
||||
runtime.events.on("comms",handleCommsEvent);
|
||||
runtime.events.removeListener("event-log",handleEventLog);
|
||||
runtime.events.on("event-log",handleEventLog);
|
||||
},
|
||||
|
||||
/**
|
||||
|
Reference in New Issue
Block a user