Merged in feature/wrap-logging (pull request #2511)

Feature/wrap logging

* feat: change all logging to go through our own logger function so that we can control log levels

* move packages/trpc to using our own logger

* merge


Approved-by: Linus Flood
This commit is contained in:
Joakim Jäderberg
2025-07-03 12:37:04 +00:00
parent 7e32ed294d
commit daf765f3d5
110 changed files with 681 additions and 441 deletions

View File

@@ -1,6 +1,8 @@
import * as Sentry from "@sentry/nextjs"
import { z } from "zod"
import { createLogger } from "@scandic-hotels/common/logger/createLogger"
import * as api from "../../../api"
import { protectedProcedure } from "../../../procedures"
import { getOTPState } from "./otp/getOTPState"
@@ -18,13 +20,14 @@ const outputSchema = z.object({
]),
})
const sasLogger = createLogger("SAS")
export const linkAccount = protectedProcedure
.output(outputSchema)
.mutation(async function ({ ctx }) {
const sasAuthToken = await getSasToken()
const { referenceId } = await getOTPState()
console.log("[SAS] link account")
sasLogger.debug("[SAS] link account")
const apiResponse = await api.post(api.endpoints.v1.Profile.link, {
headers: {
@@ -47,7 +50,7 @@ export const linkAccount = protectedProcedure
linkedAndBoosted || linkedWithoutBoost || linkedWithUnknownBoost
if (linked) {
console.log("[SAS] link account done")
sasLogger.debug("[SAS] link account done")
return { linkingState: "linked" }
}
@@ -56,12 +59,12 @@ export const linkAccount = protectedProcedure
const data = badRequestSchema.safeParse(result)
if (!data.success) {
const linkAccountBadRequestSchemaError = `[SAS] failed to parse link account bad request schema ${JSON.stringify(data.error)}`
console.error(linkAccountBadRequestSchemaError)
sasLogger.error(linkAccountBadRequestSchemaError)
Sentry.captureMessage(linkAccountBadRequestSchemaError)
return { linkingState: "error" }
}
console.log("[SAS] link account error with response", result)
sasLogger.error("[SAS] link account error with response", result)
const { errors } = data.data
@@ -89,7 +92,7 @@ export const linkAccount = protectedProcedure
}
const errorMessage = `[SAS] link account error with status code ${apiResponse.status} and response ${await apiResponse.text()}`
console.warn(errorMessage)
sasLogger.error(errorMessage)
Sentry.captureMessage(errorMessage)
return { linkingState: "error" }
})