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,7 @@
import { z, ZodError, ZodIssueCode } from "zod"
import { Lang } from "@scandic-hotels/common/constants/language"
import { logger } from "@scandic-hotels/common/logger"
import { removeMultipleSlashes } from "@scandic-hotels/common/utils/url"
import { AlertTypeEnum } from "../../../types/alertType"
@@ -541,7 +542,7 @@ export const headerRefsSchema = z
})
.transform((data) => {
if (!data.all_header.items.length) {
console.info(`Zod Error - No header returned in refs request`)
logger.error(`Zod Error - No header returned in refs request`)
throw new ZodError([
{
code: ZodIssueCode.custom,
@@ -688,7 +689,7 @@ export const headerSchema = z
})
.transform((data) => {
if (!data.all_header.items.length) {
console.info(`Zod Error - No header returned in request`)
logger.error(`Zod Error - No header returned in request`)
throw new ZodError([
{
code: ZodIssueCode.custom,

View File

@@ -1,4 +1,5 @@
import { Lang } from "@scandic-hotels/common/constants/language"
import { createLogger } from "@scandic-hotels/common/logger/createLogger"
import { createCounter } from "@scandic-hotels/common/telemetry"
import { removeTrailingSlash } from "@scandic-hotels/common/utils/url"
@@ -68,6 +69,10 @@ export async function getUrlsOfAllLanguages(
uid: string,
contentType: string
) {
const languageSwitcherLogger = createLogger(
"trpc.contentstack.languageSwitcher"
)
const getLanguageSwitcherCounter = createCounter(
"trpc.contentstack",
"languageSwitcher.get"
@@ -143,8 +148,9 @@ export async function getUrlsOfAllLanguages(
fiNoSvDocument = GetFiNoSvUrlsStartPage
break
default:
console.error(`type: [${contentType}]`)
console.error(`Trying to get a content type that is not supported`)
languageSwitcherLogger.error(
`Trying to get a content type that is not supported, ${contentType}`
)
throw internalServerError()
}