Skip to content

Commit 1ef4833

Browse files
[8.19] Audit Logs Levels - Obs Ux Logs Team (#218413) (#220388)
# Backport This will backport the following commits from `main` to `8.19`: - [Audit Logs Levels - Obs Ux Logs Team (#218413)](#218413) <!--- Backport version: 9.6.6 --> ### Questions ? Please refer to the [Backport tool documentation](https://github.com/sorenlouv/backport) <!--BACKPORT [{"author":{"name":"Abdul Wahab Zahid","email":"[email protected]"},"sourceCommit":{"committedDate":"2025-05-07T14:48:54Z","message":"Audit Logs Levels - Obs Ux Logs Team (#218413)\n\nThe PR audits and fixes the log levels for Dataset Quality plugin based on [guidelines](https://docs.elastic.dev/kibana-dev-docs/services/logging#log-level).","sha":"cf2091d5dca8aea47bec12ee14678382b36f9d1b","branchLabelMapping":{"^v9.1.0$":"main","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["release_note:skip","backport:prev-minor","backport:prev-major","v9.1.0"],"title":"Audit Logs Levels - Obs Ux Logs Team","number":218413,"url":"https://github.com/elastic/kibana/pull/218413","mergeCommit":{"message":"Audit Logs Levels - Obs Ux Logs Team (#218413)\n\nThe PR audits and fixes the log levels for Dataset Quality plugin based on [guidelines](https://docs.elastic.dev/kibana-dev-docs/services/logging#log-level).","sha":"cf2091d5dca8aea47bec12ee14678382b36f9d1b"}},"sourceBranch":"main","suggestedTargetBranches":[],"targetPullRequestStates":[{"branch":"main","label":"v9.1.0","branchLabelMappingKey":"^v9.1.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/218413","number":218413,"mergeCommit":{"message":"Audit Logs Levels - Obs Ux Logs Team (#218413)\n\nThe PR audits and fixes the log levels for Dataset Quality plugin based on [guidelines](https://docs.elastic.dev/kibana-dev-docs/services/logging#log-level).","sha":"cf2091d5dca8aea47bec12ee14678382b36f9d1b"}}]}] BACKPORT--> Co-authored-by: Abdul Wahab Zahid <[email protected]>
1 parent e9c1396 commit 1ef4833

File tree

1 file changed

+17
-3
lines changed

1 file changed

+17
-3
lines changed

x-pack/platform/plugins/shared/dataset_quality/server/routes/register_routes.ts

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -79,15 +79,13 @@ export function registerRoutes({
7979
return response.ok({ body: data });
8080
} catch (error) {
8181
if (Boom.isBoom(error)) {
82-
logger.error(error.output.payload.message);
82+
logRouteError(logger, error);
8383
return response.customError({
8484
statusCode: error.output.statusCode,
8585
body: { message: error.output.payload.message },
8686
});
8787
}
8888

89-
logger.error(error);
90-
9189
const opts = {
9290
statusCode: 500,
9391
body: {
@@ -100,9 +98,25 @@ export function registerRoutes({
10098
opts.body.message = 'Client closed request';
10199
}
102100

101+
logRouteError(logger, opts);
102+
103103
return response.customError(opts);
104104
}
105105
}
106106
);
107107
});
108108
}
109+
110+
function logRouteError(
111+
logger: Logger,
112+
error: { statusCode: number; body: { message: string } } | Boom.Boom
113+
) {
114+
const errorStatusCode = 'statusCode' in error ? error.statusCode : error.output.statusCode;
115+
const errorMessage = Boom.isBoom(error) ? error.output.payload.message : error.body.message;
116+
117+
if (errorStatusCode >= 500) {
118+
logger.error(errorMessage);
119+
} else {
120+
logger.debug(errorMessage);
121+
}
122+
}

0 commit comments

Comments
 (0)