Nodes log via parent flow to allow flow-info to be added

This commit is contained in:
Nick O'Leary
2020-09-02 19:33:12 +01:00
committed by Nick O'Leary
parent 9a660f3fe9
commit 0c9fd25d3e
4 changed files with 23 additions and 23 deletions

View File

@@ -93,7 +93,7 @@ class Flow {
* @param {[type]} msg [description]
* @return {[type]} [description]
*/
log(msg) {
info(msg) {
Log.log({
id: this.id||"global",
level: Log.INFO,
@@ -116,6 +116,17 @@ class Flow {
})
}
/**
* [log description]
* @param {[type]} msg [description]
* @return {[type]} [description]
*/
log(msg) {
if (!msg.path) {
msg.path = this.path;
}
this.parent.log(msg);
}
/**
* Start this flow.

View File

@@ -698,7 +698,8 @@ const flowAPI = {
getNode: getNode,
handleError: () => false,
handleStatus: () => false,
getSetting: k => flowUtil.getEnvVar(k)
getSetting: k => flowUtil.getEnvVar(k),
log: m => log.log(m)
}

View File

@@ -486,16 +486,14 @@ function log_helper(self, level, msg) {
if (self._alias) {
o._alias = self._alias;
}
if (self._flow) {
o.path = self._flow.path;
}
if (self.z) {
o.z = self.z;
}
if (self.name) {
o.name = self.name;
}
Log.log(o);
self._flow.log(o);
}
/**
* Log an INFO level message