Skip to content

Commit

Permalink
Merge 92fc2b8 into 7dd47a4
Browse files Browse the repository at this point in the history
  • Loading branch information
niekcandaele committed Jul 1, 2020
2 parents 7dd47a4 + 92fc2b8 commit edf65c2
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 6 deletions.
12 changes: 9 additions & 3 deletions api/hooks/sdtdLogs/LoggingObject.js
Original file line number Diff line number Diff line change
Expand Up @@ -93,15 +93,21 @@ class LoggingObject extends EventEmitter {
return;
}

console.log(result.logs);
console.log(result.logs.length);


if (result.logs.length === 0) {
this.emptyResponses++;
if (this.emptyResponses > 5) {
// havn't found any responses in a while, so reset to 0 and try again from scratch
// haven't found any responses in a while, so reset to 0 and try again from scratch
await this.setLastLogLine(0);
}
} else {
}

if (result.lastLogLine) {
// save the log line we found
await this.setLastLogLine(result.lastLogLine + 1);
await this.setLastLogLine(result.lastLogLine);
}

for (const newLog of result.logs) {
Expand Down
6 changes: 3 additions & 3 deletions test/unit/hooks/sdtdlogs/LoggingObject.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ describe('LoggingObject', function () {
const emitSpy = sandbox.spy(loggingObject, 'emit');

await loggingObject.handleCompletedJob(job, JSON.stringify(result));
expect(loggingObject.lastLogLine).to.equal(111);
expect(loggingObject.lastLogLine).to.equal(110);
expect(loggingObject.emptyResponses).to.equal(0);
expect(loggingObject.failed).to.equal(false);
expect(loggingObject.slowmode).to.equal(false);
Expand All @@ -193,7 +193,7 @@ describe('LoggingObject', function () {
const emitSpy = sandbox.spy(loggingObject, 'emit');

await loggingObject.handleCompletedJob(job, JSON.stringify(result));
expect(loggingObject.lastLogLine).to.equal(111);
expect(loggingObject.lastLogLine).to.equal(110);
expect(loggingObject.emptyResponses).to.equal(0);
expect(loggingObject.failed).to.equal(false);
expect(loggingObject.slowmode).to.equal(false);
Expand All @@ -219,7 +219,7 @@ describe('LoggingObject', function () {
const emitSpy = sandbox.spy(loggingObject, 'emit');

await loggingObject.handleCompletedJob(job, JSON.stringify(result));
expect(loggingObject.lastLogLine).to.equal(111);
expect(loggingObject.lastLogLine).to.equal(110);
expect(loggingObject.emptyResponses).to.equal(0);
expect(loggingObject.failed).to.equal(false);
expect(loggingObject.slowmode).to.equal(false);
Expand Down

0 comments on commit edf65c2

Please sign in to comment.