Skip to content

Commit

Permalink
fix(core): log.log should be bound to log.info, fixes #436
Browse files Browse the repository at this point in the history
  • Loading branch information
megahertz committed Sep 6, 2024
1 parent 0b60fc4 commit a52f3e5
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/core/Logger.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,10 +53,11 @@ class Logger {
this.variables = variables || {};
this.scope = scopeFactory(this);

this.addLevel('log', false);
for (const name of this.levels) {
this.addLevel(name, false);
}
this.log = this.info;
this.functions.log = this.log;

this.errorHandler = errorHandler;
errorHandler?.setOptions({ ...dependencies, logFn: this.error });
Expand Down Expand Up @@ -114,6 +115,7 @@ class Logger {
compareLevels(passLevel, checkLevel, levels = this.levels) {
const pass = levels.indexOf(passLevel);
const check = levels.indexOf(checkLevel);

if (check === -1 || pass === -1) {
return true;
}
Expand Down
6 changes: 6 additions & 0 deletions src/core/__specs__/Logger.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,12 @@ describe('Logger', () => {
expect(log.memory[0]).toMatchObject({ data: ['test'], level: 'info' });
});

it('should bind the log level to the info', () => {
const log = createLogger();
log.log('test');
expect(log.memory[0]).toMatchObject({ data: ['test'], level: 'info' });
});

it('should process undefined value', () => {
const log = createLogger();
log.info(undefined);
Expand Down

0 comments on commit a52f3e5

Please sign in to comment.