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"
@@ -14,6 +16,7 @@ const transferPointsInputSchema = z.object({
points: z.number(),
})
const sasLogger = createLogger("SAS")
export const transferPoints = protectedProcedure
.output(outputSchema)
.input(transferPointsInputSchema)
@@ -43,20 +46,20 @@ export const transferPoints = protectedProcedure
const data = badRequestSchema.safeParse(result)
if (!data.success) {
const transferPointsBadRequestSchemaError = `[SAS] failed to parse transfer points bad request schema ${JSON.stringify(data.error)}`
console.error(transferPointsBadRequestSchemaError)
sasLogger.error(transferPointsBadRequestSchemaError)
Sentry.captureMessage(transferPointsBadRequestSchemaError)
return { transferState: "error" }
}
}
if (apiResponse.status === 404) {
const transferPointsNotFoundError = `[SAS] transfer points failed, no active partner link`
console.error(transferPointsNotFoundError)
sasLogger.error(transferPointsNotFoundError)
Sentry.captureMessage(transferPointsNotFoundError)
return { transferState: "notLinked" }
}
const errorMessage = `[SAS] transfer points error with status code ${apiResponse.status} and response ${await apiResponse.text()}`
console.warn(errorMessage)
sasLogger.error(errorMessage)
Sentry.captureMessage(errorMessage)
return { transferState: "error" }
})