fix(api): update logging (#60210)

This commit is contained in:
Mrugesh Mohapatra
2025-05-07 15:30:32 +05:30
committed by GitHub
parent 8e86fac378
commit 8a6fcd70db
2 changed files with 12 additions and 4 deletions

View File

@@ -222,8 +222,10 @@ export const userPublicGetRoutes: FastifyPluginCallbackTypebox = (
const logger = fastify.log.child({ req, res: reply });
if (req.validationError) {
logger.warn('Validation error: No username provided');
void reply.code(400);
logger
.child({ res: reply })
.warn('Validation error: No username provided');
return await reply.send({
type: 'danger',
message: 'username parameter is required'

View File

@@ -19,6 +19,12 @@ const serializersPretty = {
REQ_METHOD: req.method,
REQ_URL: req.url
};
},
res: (res: FastifyReply) => {
return {
RES_STATUS_CODE: res.statusCode,
RES_ELAPSED_TIME: res.elapsedTime
};
}
};
@@ -50,10 +56,10 @@ const serializersDefault = {
REQ_ID: id
};
},
res: (reply: FastifyReply) => {
res: (res: FastifyReply) => {
return {
RES_STATUS_CODE: reply.statusCode,
RES_RESPONSE_TIME: reply.elapsedTime
RES_STATUS_CODE: res.statusCode,
RES_ELAPSED_TIME: res.elapsedTime
};
}
};