Skip to content
This repository has been archived by the owner on Oct 17, 2020. It is now read-only.

Commit

Permalink
Return a dummy PluginLogger if none is registered.
Browse files Browse the repository at this point in the history
Fixes #85
  • Loading branch information
ivan-zaera authored and jbalsas committed Mar 14, 2018
1 parent 704adeb commit f2fd122
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,18 @@ describe('when using PlugginLogger registration', () => {

PluginLogger.set('a-key', logger);

expect(PluginLogger.get('a-key')).toBe(logger);
logger.info('source', 'hi');

expect(PluginLogger.get('a-key').messages.length).toBe(1);

PluginLogger.delete('a-key');

expect(PluginLogger.get('a-key').messages.length).toBe(0);
});

it('returns a dummy logger if no loggers are registered', () => {
PluginLogger.delete('a-key');

expect(PluginLogger.get('a-key')).toBeUndefined();
expect(PluginLogger.get('a-key')).toBeDefined();
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ PluginLogger.get = function(key) {
key = key.file.opts.filenameRelative;
}

return global._PluginLogger_[key];
return global._PluginLogger_[key] || new PluginLogger();
};

/**
Expand Down

0 comments on commit f2fd122

Please sign in to comment.