mirror of
https://github.com/freeCodeCamp/freeCodeCamp.git
synced 2026-01-07 09:03:27 -05:00
fix(api): update logging (#60210)
This commit is contained in:
committed by
GitHub
parent
8e86fac378
commit
8a6fcd70db
@@ -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'
|
||||
|
||||
@@ -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
|
||||
};
|
||||
}
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user