Skip to content

Commit b787e85

Browse files
committed
ojob: adding logJobs and correcting logLimit
1 parent 8049296 commit b787e85

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

js/owrap.oJob.js

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,8 @@ OpenWrap.oJob.prototype.load = function(jobs, todo, ojob, args, aId) {
7676

7777
if (isDef(ojob.numThreads)) this.__ojob.numThreads = ojob.numThreads;
7878
if (isDef(ojob.logToConsole)) this.__ojob.logToConsole = ojob.logToConsole;
79-
if (isDef(ojob.logLimit)) this.__logLimit = ojob.__logLimit;
79+
if (isDef(ojob.logLimit)) this.__logLimit = ojob.logLimit;
80+
ojob.logJobs = _$(ojob.logJobs).default(true);
8081
if (isDef(ojob.logToFile) && isMap(ojob.logToFile)) {
8182
ow.ch.utils.setLogToFile(ojob.logToFile);
8283
}
@@ -581,19 +582,19 @@ OpenWrap.oJob.prototype.__addLog = function(aOp, aJobName, aJobExecId, args, anE
581582
var __d = (new Date()).toJSON(); var __n = nowNano();
582583
var __m = msg + "STARTED" + sep + __d;
583584
if (this.__ojob.logToConsole) { printnl(_b(__m) + "\n" + _g(aa) + _c(s)); }
584-
if (isDef(getChLog())) getChLog().set({ n: nowNano(), d: __d, t: "INFO" }, { n: nowNano(), d: __d, t: "INFO", m: __m });
585+
if (isDef(getChLog()) && this.__ojob.logJobs) getChLog().set({ n: nowNano(), d: __d, t: "INFO" }, { n: nowNano(), d: __d, t: "INFO", m: __m });
585586
}
586587
if (existing.start && existing.error) {
587588
var __d = (new Date()).toJSON(); var __n = nowNano();
588589
var __m = msg + "Ended in ERROR" + sep + __d;
589590
if (this.__ojob.logToConsole) { printErr("\n" + _e(ss) + _g(aa) + _b(__m) + "\n" + stringify(existing) + "\n" + _e(ss)); }
590-
if (isDef(getChLog())) getChLog().set({ n: nowNano(), d: __d, t: "ERROR" }, { n: nowNano(), d: __d, t: "ERROR", m: __m + "\n" + stringify(existing) });
591+
if (isDef(getChLog()) && this.__ojob.logJobs) getChLog().set({ n: nowNano(), d: __d, t: "ERROR" }, { n: nowNano(), d: __d, t: "ERROR", m: __m + "\n" + stringify(existing) });
591592
}
592593
if (existing.start && existing.success) {
593594
var __d = (new Date()).toJSON(); var __n = nowNano();
594595
var __m = msg + "Ended with SUCCESS" + sep + __d;
595596
if (this.__ojob.logToConsole) { printnl("\n" + _c(ss)); print(_g(aa) +_b(__m) + "\n"); }
596-
if (isDef(getChLog())) getChLog().set({ n: nowNano(), d: __d, t: "INFO" }, { n: nowNano(), d: __d, t: "INFO", m: __m });
597+
if (isDef(getChLog()) && this.__ojob.logJobs) getChLog().set({ n: nowNano(), d: __d, t: "INFO" }, { n: nowNano(), d: __d, t: "INFO", m: __m });
597598
}
598599
}
599600
} catch(e) {
@@ -604,7 +605,7 @@ OpenWrap.oJob.prototype.__addLog = function(aOp, aJobName, aJobExecId, args, anE
604605
};
605606

606607
// Housekeeping
607-
if (existing.log.length > this.__logLimit) existing.log.shift();
608+
while (existing.log.length > this.__logLimit) existing.log.shift();
608609

609610
this.getLogCh().set({ "ojobId": this.__id + aId, "name": aJobName }, existing);
610611
}

0 commit comments

Comments
 (0)