Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: STRF-10408 Fix unknown level error #257

Merged
merged 1 commit into from
Mar 17, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -360,7 +360,7 @@ class HandlebarsRenderer {
*/
_overrideConsoleLog() {
if (this.logger !== console) {
console.log = this.logger.log.bind(this.logger);
console.log = this.logger.info.bind(this.logger);
console.info = this.logger.info.bind(this.logger);
console.error = this.logger.error.bind(this.logger);
console.warn = this.logger.warn.bind(this.logger);
Expand Down
7 changes: 3 additions & 4 deletions spec/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -417,7 +417,6 @@ describe('logging', () => {
beforeEach(done => {
sandbox = Sinon.createSandbox();
logger = {
log: Sinon.fake(),
info: Sinon.fake(),
warn: Sinon.fake(),
error: Sinon.fake(),
Expand Down Expand Up @@ -448,15 +447,15 @@ describe('logging', () => {
it('log helper should not be called, when log level = error', done => {
renderer = new HandlebarsRenderer({}, {}, 'v4', logger, 'error');
renderer.renderString('{{log bar}}', context).then(() => {
expect(logger.log.called).to.equal(false);
expect(logger.info.called).to.equal(false);
done();
});
});

it('log helper should not be called, when log level = warning', done => {
renderer = new HandlebarsRenderer({}, {}, 'v4', logger, 'warning');
renderer.renderString('{{log bar}}', context).then(() => {
expect(logger.log.called).to.equal(false);
expect(logger.info.called).to.equal(false);
done();
});
});
Expand Down Expand Up @@ -489,7 +488,7 @@ describe('logging', () => {
it('should override default console.log', done => {
renderer = new HandlebarsRenderer({}, {}, 'v4', logger);
console.log('test');
expect(logger.log.calledWith('test')).to.equal(true);
expect(logger.info.calledWith('test')).to.equal(true);
done();
});

Expand Down