Skip to content

Commit

Permalink
Merge pull request #19 from starsprung/fix-filtering-bug
Browse files Browse the repository at this point in the history
Fixed issue where checkpoint would not advance if all logs were filtered out
  • Loading branch information
fyockm authored Jun 15, 2018
2 parents f14a77e + 373dbe5 commit f160f3c
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 2 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "auth0-log-extension-tools",
"version": "1.3.5",
"version": "1.3.6",
"description": "A set of tools for logging",
"main": "src/index.js",
"dependencies": {
Expand Down
2 changes: 1 addition & 1 deletion src/processor.js
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ LogsProcessor.prototype.run = function(handler) {
options.logger.debug('Processor run complete. Logs processed:', status.logsProcessed);
}

if (status.logsProcessed > 0) {
if (checkpoint !== status.startCheckpoint) {
const week = 604800000;
const currentDate = new Date().getTime();
const timeDiff = currentDate - lastLogDate;
Expand Down
1 change: 1 addition & 0 deletions src/stream.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ function LogsApiStream(options) {
this.previousCheckpoint = options.checkpointId || null;
this.lastCheckpoint = options.checkpointId || null;
this.status = {
startCheckpoint: options.checkpointId || null,
start: new Date(),
end: null,
logsProcessed: 0
Expand Down
20 changes: 20 additions & 0 deletions tests/lib/processor.tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -247,6 +247,26 @@ describe('LogsProcessor', () => {
});
});

it('should update checkpoint even if no events match given logTypes', () => {
helpers.mocks.logs({ delay: 550, type: 'sapi' });


const storage = webtaskStorage();
const getAsync = Promise.promisify(storage.get);

const processor = createProcessor(null, { logTypes: [ 's', 'ss' ] }, storage);
return processor.run((logs, cb) => setTimeout(cb()))
.then(() => getAsync())
.then((storageState) => {
expect(storageState.checkpointId).to.equal('100');
expect(storageState.logs[0].logsProcessed).to.equal(0);
expect(storageState.logs[0].checkpoint).to.equal('100');
expect(storageState.logs[0].start).to.be.an.instanceof(Date);
expect(storageState.logs[0].end).to.be.an.instanceof(Date);
});
});


it('should return report', () => {
const data = {
logs: [
Expand Down

0 comments on commit f160f3c

Please sign in to comment.