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 NextAuth, { type NextAuthConfig } from "next-auth"
import MicrosoftEntraID from "next-auth/providers/microsoft-entra-id"
import { logger } from "@scandic-hotels/common/logger"
import { env } from "@/env/server"
const config = {
@@ -40,9 +42,9 @@ const config = {
return session
},
async redirect({ baseUrl, url }) {
console.log(`[auth.dtmc] deciding redirect URL`, { baseUrl, url })
logger.debug(`[auth.dtmc] deciding redirect URL`, { baseUrl, url })
if (url.startsWith("/")) {
console.log(
logger.debug(
`[auth.dtmc] relative URL accepted, returning: ${baseUrl}${url}`
)
// Allows relative callback URLs
@@ -54,22 +56,24 @@ const config = {
if (
/\.scandichotels\.(dk|de|com|fi|no|se)$/.test(parsedUrl.hostname)
) {
console.log(`[auth.dtmc] subdomain URL accepted, returning: ${url}`)
logger.debug(
`[auth.dtmc] subdomain URL accepted, returning: ${url}`
)
// Allows any subdomains on all top level domains above
return url
} else if (parsedUrl.origin === baseUrl) {
// Allows callback URLs on the same origin
console.log(`[auth.dtmc] origin URL accepted, returning: ${url}`)
logger.debug(`[auth.dtmc] origin URL accepted, returning: ${url}`)
return url
}
} catch (e) {
console.error(
logger.error(
`[auth.dtmc] error parsing incoming URL for redirection`,
e
)
}
}
console.log(`[auth.dtmc] URL denied, returning base URL: ${baseUrl}`)
logger.debug(`[auth.dtmc] URL denied, returning base URL: ${baseUrl}`)
return baseUrl
},
async authorized() {