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:
parent
90818700a3
commit
2c594910d8
3 changed files with 31 additions and 1 deletions
5
.changeset/shaggy-carrots-unite.md
Normal file
5
.changeset/shaggy-carrots-unite.md
Normal file
|
@ -0,0 +1,5 @@
|
|||
---
|
||||
'@verdaccio/logger': patch
|
||||
---
|
||||
|
||||
do not show deprecation warning on default logger config
|
|
@ -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) {
|
||||
|
|
|
@ -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();
|
||||
});
|
||||
});
|
||||
|
|
Loading…
Reference in a new issue