0
Fork 0
mirror of https://github.com/verdaccio/verdaccio.git synced 2024-12-16 21:56:25 -05:00

fix: do not throw multiple logger deprecation warning if using default logger config (#2446)

This commit is contained in:
Zameer Haque 2021-09-19 23:50:46 +05:30 committed by GitHub
parent 90818700a3
commit 2c594910d8
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 31 additions and 1 deletions

View file

@ -0,0 +1,5 @@
---
'@verdaccio/logger': patch
---
do not show deprecation warning on default logger config

View file

@ -98,7 +98,7 @@ export type LoggerConfigItem = {
export type LoggerConfig = LoggerConfigItem[];
export function setup(options: LoggerConfig | LoggerConfigItem = [DEFAULT_LOGGER_CONF]) {
export function setup(options: LoggerConfig | LoggerConfigItem = DEFAULT_LOGGER_CONF) {
debug('setup logger');
const isLegacyConf = Array.isArray(options);
if (isLegacyConf) {

View file

@ -13,4 +13,29 @@ describe('logger', () => {
// FIXME: check expect
// expect(spyOn).toHaveBeenCalledTimes(2);
});
test('throw deprecation warning if multiple loggers configured', () => {
const spy = jest.spyOn(process, 'emitWarning');
setup([
{
level: 'info',
},
{
level: 'http',
},
]);
expect(spy).toHaveBeenCalledWith(
'deprecate: multiple logger configuration is deprecated, please check the migration guide.'
);
spy.mockRestore();
});
test('regression: do not throw deprecation warning if no logger config is provided', () => {
const spy = jest.spyOn(process, 'emitWarning');
setup();
expect(spy).not.toHaveBeenCalledWith(
'deprecate: multiple logger configuration is deprecated, please check the migration guide.'
);
spy.mockRestore();
});
});