Skip to content
This repository has been archived by the owner on Feb 20, 2023. It is now read-only.

Commit

Permalink
fix(logging): Moves objects to start of log call
Browse files Browse the repository at this point in the history
Pino expects the object that should be logged to be at the beginning of
the log. call
  • Loading branch information
ff6347 committed Mar 15, 2022
1 parent 944ab1c commit 26d5691
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 10 deletions.
4 changes: 2 additions & 2 deletions src/integrations/http.ts
Original file line number Diff line number Diff line change
Expand Up @@ -121,9 +121,9 @@ const http: FastifyPluginAsync = async (fastify) => {
})
.eq("id", sensors[0].id);
if (updateError) {
fastify.log.error("Error while updating lat, lon, alt", updateError);
fastify.log.error(updateError, "Error while updating lat, lon, alt");
}
fastify.log.info("updated lat, lon, alt", updatedSensors);
fastify.log.info(updatedSensors, "updated lat, lon, alt");

const recordedAt = new Date().toISOString();
const { data: record, error: recordError } = await fastify.supabase
Expand Down
4 changes: 2 additions & 2 deletions src/integrations/ttn.ts
Original file line number Diff line number Diff line change
Expand Up @@ -170,9 +170,9 @@ const ttn: FastifyPluginAsync = async (fastify) => {
.eq("id", sensors[0].id);

if (updateError) {
fastify.log.error("Error while updating lat, lon, alt", updateError);
fastify.log.error(updateError, "Error while updating lat, lon, alt");
}
fastify.log.info("updated lat, lon, alt", updatedSensors);
fastify.log.info(updatedSensors, "updated lat, lon, alt");

// console.log(
// new Date(received_at).toISOString().replace("T", " ").replace("Z", "")
Expand Down
2 changes: 1 addition & 1 deletion src/lib/sensors-records.ts
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,7 @@ const sensorsRecordsRoutes: FastifyPluginAsync = async (fastify) => {
// hm records are null but they should not.
// we cant do anything for the user
if (!records) {
fastify.log.error("records are null but should not", sensorId);
fastify.log.error(sensorId, "records are null but should not");
throw fastify.httpErrors.internalServerError();
}
// this is for pagination in header and in payload
Expand Down
6 changes: 1 addition & 5 deletions src/lib/signup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ const signupPlugin: FastifyPluginAsync<SignupPluginOptions> = async (
try {
isEmailTaken = await checkEmail(email);
} catch (error) {
fastify.log.error("pg db request error", error);
fastify.log.error(error, "pg db request error");
throw fastify.httpErrors.internalServerError();
}
if (isEmailTaken === true) {
Expand Down Expand Up @@ -164,10 +164,6 @@ const signupPlugin: FastifyPluginAsync<SignupPluginOptions> = async (
payload: { email, name },
});
reply.status(204).send(payload);
// } catch (error) {
// fastify.log.error("db error", error);
// throw fastify.httpErrors.internalServerError();
// }
},
});
};
Expand Down

0 comments on commit 26d5691

Please sign in to comment.