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,5 +1,7 @@
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"
@@ -8,7 +10,7 @@ import { getSasToken } from "./getSasToken"
const outputSchema = z.object({
linkingState: z.enum(["unlinked", "notLinked", "error"]),
})
const sasLogger = createLogger("SAS")
export const unlinkAccount = protectedProcedure
.output(outputSchema)
.mutation(async function ({ ctx }) {
@@ -29,24 +31,24 @@ export const unlinkAccount = protectedProcedure
})
if (apiResponse.status === 204 || apiResponse.status === 202) {
console.log("[SAS] unlink account success")
sasLogger.debug("unlink account success")
return { linkingState: "unlinked" }
}
if (apiResponse.status === 400) {
const result = await apiResponse.json()
console.log("[SAS] unlink account error with response", result)
sasLogger.debug("unlink account error with response", result)
return { linkingState: "error" }
}
if (apiResponse.status === 404) {
console.log("[SAS] tried unlinking an account that was not linked")
sasLogger.debug("tried unlinking an account that was not linked")
return { linkingState: "notLinked" }
}
console.log(
`[SAS] unlink account error with status code ${apiResponse.status} and response ${await apiResponse.text()}`
sasLogger.debug(
`unlink account error with status code ${apiResponse.status} and response ${await apiResponse.text()}`
)
return { linkingState: "error" }
})