mirror of
https://github.com/Unleash/unleash.git
synced 2024-12-22 19:07:54 +01:00
ccaab0c47b
Instead of instructing users to do static calls in to Unleash, she should instead be allwed to specify the log provider as an option to Unleash. This commit introduces the "getLogger" option, a function responsible for creating a logger.
35 lines
936 B
JavaScript
35 lines
936 B
JavaScript
'use strict';
|
|
|
|
const test = require('ava');
|
|
const logger = require('./logger');
|
|
|
|
test('should expose a setLoggerProvider function', t => {
|
|
t.true(logger.setLoggerProvider instanceof Function);
|
|
});
|
|
|
|
test('should require custom logger to implement info', t => {
|
|
const loggerImpl = {
|
|
debug: () => {},
|
|
warn: () => {},
|
|
error: () => {},
|
|
};
|
|
const provider = () => loggerImpl;
|
|
const error = t.throws(() => {
|
|
logger.setLoggerProvider(provider)();
|
|
}, TypeError);
|
|
t.is(error.message, 'Logger must implement info');
|
|
});
|
|
|
|
test('should require custom logger to implement error', t => {
|
|
const loggerImpl = {
|
|
debug: () => {},
|
|
warn: () => {},
|
|
info: () => {},
|
|
};
|
|
const provider = () => loggerImpl;
|
|
const error = t.throws(() => {
|
|
logger.setLoggerProvider(provider)();
|
|
}, TypeError);
|
|
t.is(error.message, 'Logger must implement error');
|
|
});
|