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 { z } from "zod"
import { logger } from "@scandic-hotels/common/logger"
import { phoneValidator } from "@scandic-hotels/common/utils/zod/phoneValidator"
import * as api from "@scandic-hotels/trpc/api"
import { ApiLang } from "@scandic-hotels/trpc/constants/apiLang"
@@ -47,7 +48,7 @@ export const editProfile = protectedServerActionProcedure
const intl = await getIntl()
const payload = editProfilePayload.safeParse(input)
if (!payload.success) {
console.error(
logger.error(
"editProfile payload validation error",
JSON.stringify({
query: input,
@@ -70,7 +71,7 @@ export const editProfile = protectedServerActionProcedure
const profile = await getProfile()
if (!profile || "error" in profile) {
console.error(
logger.error(
"editProfile profile fetch error",
JSON.stringify({
query: input,
@@ -144,7 +145,7 @@ export const editProfile = protectedServerActionProcedure
status: Status.success,
}
} else {
console.log(
logger.debug(
`[edit profile: ${profile.membershipNumber}] body keys: ${JSON.stringify(Object.keys(body))}`
)
}
@@ -159,7 +160,7 @@ export const editProfile = protectedServerActionProcedure
if (!apiResponse.ok) {
const text = await apiResponse.text()
console.error(
logger.error(
"editProfile api patch error",
JSON.stringify({
query: input,
@@ -184,7 +185,7 @@ export const editProfile = protectedServerActionProcedure
const json = await apiResponse.json()
if (json.errors?.length) {
json.errors.forEach((error: any) => {
console.warn(
logger.warn(
"editProfile api patch errors (not aborting)",
JSON.stringify({
query: input,
@@ -196,7 +197,7 @@ export const editProfile = protectedServerActionProcedure
const validatedData = editProfileSchema.safeParse(json.data.attributes)
if (!validatedData.success) {
console.error(
logger.error(
"editProfile validation error",
JSON.stringify({
query: input,