Skip to content

Commit b983738

Browse files
committed
fix(log-factory): make it more explicit that the data attribute is optional
1 parent 7b6fa2a commit b983738

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

src/logger/logger.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ Logger.config = {
9696
};
9797

9898
const logMethodFactory = function(level) {
99-
return function(action, data) {
99+
return function(action, data = {}) {
100100
if (!this._enabled) {
101101
return;
102102
}

src/logger/logger.spec.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,15 @@ describe('Logger', function() {
3131
expect(logArguments.details).to.eql('forever');
3232
});
3333

34+
it('should be callable without the data object', function() {
35+
logger.info('wedidit');
36+
37+
const logArguments = JSON.parse(Logger.config.output.args[0]);
38+
expect(logArguments.name).to.eql('mongo');
39+
expect(logArguments.action).to.eql('wedidit');
40+
expect(logArguments.level).to.eql(30);
41+
});
42+
3443
it('should not call log info method when disabled', function() {
3544
logger = new Logger('mongo', false);
3645

0 commit comments

Comments
 (0)