Replace default warning by an info message (#145086)

Customers upgrading to 8.6 should not have warning messages for a new
feature that they have not enabled.

This PR changes the default behaviour, logging an `info` message
(instead of a `warn`) when the default connector configuration is
missing for the `'notifications'` plugin.
This commit is contained in:
Gerard Soldevila 2022-11-14 18:06:23 +01:00 committed by GitHub
parent f1117c8959
commit 261231f8c8
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 16 additions and 9 deletions

View file

@ -79,15 +79,16 @@ describe('ConnectorsEmailServiceProvider', () => {
expect(serviceProvider['setupSuccessful']).toEqual(false);
});
it('should log a warning if no default email connector has been defined', () => {
it('should log an info message if no default email connector has been defined', () => {
const serviceProvider = new EmailServiceProvider(missingConnectorConfig, logger);
serviceProvider.setup({
actions: actionsSetup,
licensing: licensingMock.createSetup(),
});
expect(logger.warn).toHaveBeenCalledTimes(1);
expect(logger.warn).toHaveBeenCalledWith(
expect(logger.warn).not.toHaveBeenCalled();
expect(logger.info).toHaveBeenCalledTimes(1);
expect(logger.info).toHaveBeenCalledWith(
`Email Service Error: Email connector not specified.`
);
// eslint-disable-next-line dot-notation

View file

@ -41,16 +41,18 @@ export class EmailServiceProvider
const { actions, licensing } = plugins;
if (!actions || !licensing) {
return this._registerServiceError(`Error: 'actions' and 'licensing' plugins are required.`);
return this._registerInitializationError(
`Error: 'actions' and 'licensing' plugins are required.`
);
}
const emailConnector = this.config.connectors?.default?.email;
if (!emailConnector) {
return this._registerServiceError('Error: Email connector not specified.');
return this._registerInitializationError('Error: Email connector not specified.', 'info');
}
if (!actions.isPreconfiguredConnector(emailConnector)) {
return this._registerServiceError(
return this._registerInitializationError(
`Error: Unexisting email connector '${emailConnector}' specified.`
);
}
@ -75,7 +77,7 @@ export class EmailServiceProvider
this.logger
);
} catch (err) {
this._registerServiceError(err);
this._registerInitializationError(err);
}
}
@ -90,9 +92,13 @@ export class EmailServiceProvider
};
}
private _registerServiceError(error: string) {
private _registerInitializationError(error: string, level: 'info' | 'warn' = 'warn') {
const message = `Email Service ${error}`;
this.setupError = message;
this.logger.warn(message);
if (level === 'info') {
this.logger.info(message);
} else {
this.logger.warn(message);
}
}
}