Skip to content

Commit

Permalink
🐛 Fix printed debug timestamps (#289)
Browse files Browse the repository at this point in the history
  • Loading branch information
Wil Wilsman authored Apr 5, 2021
1 parent e657279 commit 24edf25
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
2 changes: 1 addition & 1 deletion packages/logger/src/logger.js
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ export default class PercyLogger {
let elapsed = timestamp - (this.lastlog || timestamp);
if (isError && this.level !== 'debug') message = error.toString();
this.write(level, this.format(message, debug, error ? 'error' : level, elapsed));
this.lastlog ||= timestamp;
this.lastlog = timestamp;
}
}

Expand Down
4 changes: 3 additions & 1 deletion packages/logger/test/index.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -257,6 +257,7 @@ describe('logger', () => {
log.error('Error log');
await new Promise(r => setTimeout(r, 100));
log.debug('Debug log');
log.error('Final log');

expect(helpers.stdout).toEqual([
jasmine.stringMatching('Info log \\(\\dms\\)')
Expand All @@ -265,7 +266,8 @@ describe('logger', () => {
expect(helpers.stderr).toEqual([
jasmine.stringMatching('Warn log \\(\\dms\\)'),
jasmine.stringMatching('Error log \\(\\dms\\)'),
jasmine.stringMatching('Debug log \\((9[0-9]|1[01][0-9])ms\\)')
jasmine.stringMatching('Debug log \\((9[0-9]|1[01][0-9])ms\\)'),
jasmine.stringMatching('Final log \\(\\dms\\)')
]);
});
});
Expand Down

0 comments on commit 24edf25

Please sign in to comment.