Skip to content

Commit

Permalink
fix: verbose level ignored on update / finish
Browse files Browse the repository at this point in the history
  • Loading branch information
kshutkin committed Dec 2, 2021
1 parent c09caa4 commit b6023e3
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 2 deletions.
4 changes: 2 additions & 2 deletions logger/src/core.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,11 @@ export function createLogger<ErrorContext = Error>(...args: [] | [string | Ident
},
// Fine to be updated multiple times
update(message: string, loglevel?: LogLevel) {
append(message, Action.update, loglevel || initialLogLevel);
append(message, Action.update, loglevel ?? initialLogLevel);
},
// Fine to be finished multiple times
finish(message: string, loglevel?: LogLevel) {
append(message, Action.finish, loglevel || initialLogLevel);
append(message, Action.finish, loglevel ?? initialLogLevel);
},
withFilter(predicate: (logMessage: LogMessage<ErrorContext>) => boolean) {
myAppender = filterMessages(predicate, myAppender);
Expand Down
15 changes: 15 additions & 0 deletions logger/tests/logger.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,21 @@ describe('api tests', () => {
})
);
});

it('with overriden log level', () => {
const appenderMock = jest.fn();
appender(appenderMock);
createLogger().start('test message', LogLevel.info);
createLogger().start('test message2', LogLevel.verbose);
expect(appenderMock).toBeCalledWith(
expect.objectContaining({
action: Action.start,
inputId: expect.any(Number),
loglevel: LogLevel.verbose,
message: 'test message2'
})
);
});
});

describe('update', () => {
Expand Down

0 comments on commit b6023e3

Please sign in to comment.