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

@@ -2,6 +2,7 @@ import { cookies } from "next/headers"
import { redirect } from "next/navigation"
import { z } from "zod"
import { logger } from "@scandic-hotels/common/logger"
import { safeTry } from "@scandic-hotels/common/utils/safeTry"
import { SAS_TOKEN_STORAGE_KEY } from "@scandic-hotels/trpc/constants/partnerSAS"
@@ -35,7 +36,7 @@ export async function GET(
})
if (!result.success) {
console.error("[SAS] Invalid search params", result.error)
logger.error("[SAS] Invalid search params", result.error)
redirect(`/${lang}/sas-x-scandic/error?errorCode=invalid_query`)
}
const { code, state } = result.data
@@ -62,7 +63,7 @@ export async function GET(
if (!tokenResponse.ok) {
const error = await tokenResponse.text()
console.error("[SAS] Failed to get token", error)
logger.error("[SAS] Failed to get token", error)
redirect(`/${lang}/sas-x-scandic/error?errorCode=token_error`)
}
@@ -90,7 +91,7 @@ export async function GET(
const caller = await serverClient()
const [data, error] = await safeTry(caller.partner.sas.requestOtp())
if (!data || error) {
console.error("[SAS] Failed to request OTP", error)
logger.error("[SAS] Failed to request OTP", error)
redirect(`/${lang}/sas-x-scandic/error`)
}
@@ -107,7 +108,7 @@ export async function GET(
throw new Error(`Unhandled request OTP status ${data.status}`)
}
console.log("[SAS] Request OTP response", data)
logger.debug("[SAS] Request OTP response", data)
const otpUrl = new URL(
`/${lang}/sas-x-scandic/otp`,