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,7 +1,8 @@
import { NextRequest } from "next/server"
import { env } from "@/env/server"
import { logger } from "@scandic-hotels/common/logger"
import { env } from "@/env/server"
/**
* Use this function when you want to create URLs that are public facing, for
* example for redirects or redirectTo query parameters.
@@ -67,7 +68,7 @@ export function getInternalNextURL(request: NextRequest) {
const originHeader = request.headers.get("x-sh-origin")
if (originHeader) {
console.log(`[internalNextUrl] using x-sh-origin header`, {
logger.debug(`[internalNextUrl] using x-sh-origin header`, {
origin,
originHeader,
newOrigin: href.replace(origin, originHeader),
@@ -78,7 +79,7 @@ export function getInternalNextURL(request: NextRequest) {
const hostHeader = request.headers.get("host")
if (hostHeader) {
const inputHostOrigin = `${request.nextUrl.protocol}//${hostHeader}`
console.log(`[internalNextUrl] using host header`, {
logger.debug(`[internalNextUrl] using host header`, {
origin,
hostHeader,
hostOrigin: inputHostOrigin,
@@ -88,6 +89,6 @@ export function getInternalNextURL(request: NextRequest) {
return new NextRequest(href.replace(origin, hostOrigin), request).nextUrl
}
console.log(`[internalNextUrl] falling back to incoming request`)
logger.debug(`[internalNextUrl] falling back to incoming request`)
return request.nextUrl
}