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 { notFound } from "next/navigation"
import { logger } from "@scandic-hotels/common/logger"
import AccountPage from "@/components/Webviews/AccountPage"
import LoyaltyPage from "@/components/Webviews/LoyaltyPage"
@@ -22,7 +24,7 @@ export default async function ContentTypePage(
return <AccountPage />
default:
const type: never = params.contentType
console.error(`Unsupported content type given: ${type}`)
logger.error(`Unsupported content type given: ${type}`)
notFound()
}
}

View File

@@ -1,6 +1,9 @@
import * as Sentry from "@sentry/nextjs"
import { headers } from "next/headers"
import { redirect } from "next/navigation"
import { logger } from "@scandic-hotels/common/logger"
import { getProfile } from "@/lib/trpc/memoizedRequests"
import { getIntl } from "@/i18n"
@@ -17,7 +20,7 @@ export default async function Layout(
const user = await getProfile()
if (!user) {
console.log(`[webview:page] unable to load user`)
logger.debug(`[webview:page] unable to load user`)
return (
<p>
{intl.formatMessage({
@@ -35,7 +38,9 @@ export default async function Layout(
const headersList = await headers()
const returnURL = `/${params.lang}/webview${headersList.get("x-pathname")!}`
const redirectURL = `/${params.lang}/webview/refresh?returnUrl=${encodeURIComponent(returnURL)}`
console.log(`[webview:page] user error, redirecting to: ${redirectURL}`)
logger.debug(
`[webview:page] user error, redirecting to: ${redirectURL}`
)
redirect(redirectURL)
case "notfound":
return (
@@ -55,7 +60,8 @@ export default async function Layout(
)
default:
const u: never = user
console.log("[webview:page] unhandled user loading error", u)
logger.error("[webview:page] unhandled user loading error", u)
Sentry.captureMessage("[webview:page] unhandled user loading error", u)
}
}