Skip to content

Commit

Permalink
Use logger in package install handler.
Browse files Browse the repository at this point in the history
  • Loading branch information
skh committed May 11, 2020
1 parent dad051d commit d31c890
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions x-pack/plugins/ingest_manager/server/routes/epm/handlers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ import {
installPackage,
removeInstallation,
} from '../../services/epm/packages';
import { appContextService } from '../../services';

export const getCategoriesHandler: RequestHandler = async (context, request, response) => {
try {
Expand Down Expand Up @@ -121,10 +122,12 @@ export const getInfoHandler: RequestHandler<TypeOf<typeof GetInfoRequestSchema.p
export const installPackageHandler: RequestHandler<TypeOf<
typeof InstallPackageRequestSchema.params
>> = async (context, request, response) => {
const logger = appContextService.getLogger();
const { pkgkey } = request.params;
const savedObjectsClient = context.core.savedObjects.client;
const callCluster = context.core.elasticsearch.adminClient.callAsCurrentUser;
if (logger) logger.info(`Attempting installation of package ${pkgkey}.`);
try {
const { pkgkey } = request.params;
const savedObjectsClient = context.core.savedObjects.client;
const callCluster = context.core.elasticsearch.adminClient.callAsCurrentUser;
const res = await installPackage({
savedObjectsClient,
pkgkey,
Expand All @@ -136,6 +139,7 @@ export const installPackageHandler: RequestHandler<TypeOf<
};
return response.ok({ body });
} catch (e) {
if (logger) logger.error(`Error during installation of package ${pkgkey}: ${e}`);
if (e.isBoom) {
return response.customError({
statusCode: e.output.statusCode,
Expand Down

0 comments on commit d31c890

Please sign in to comment.