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

@@ -7,6 +7,7 @@ import {
type CacheTime,
getCacheClient,
} from "@scandic-hotels/common/dataCache"
import { createLogger } from "@scandic-hotels/common/logger/createLogger"
import { env } from "../../env/server"
import { getPreviewHash, isPreviewByUid } from "../previewContext"
@@ -25,6 +26,8 @@ export async function request<T>(
ttl: CacheTime
}
): Promise<Data<T>> {
const requestLogger = createLogger("graphql-request")
const shouldUsePreview = variables?.uid
? isPreviewByUid(variables.uid)
: false
@@ -33,12 +36,12 @@ export async function request<T>(
internalRequest<T>(query, shouldUsePreview, variables, getPreviewHash())
if (!cacheOptions) {
console.warn("[NO CACHE] for query", query)
requestLogger.warn("[NO CACHE] for query", query)
return doCall()
}
if (shouldUsePreview) {
console.log("[NO CACHE] [PREVIEW] for query", query)
requestLogger.debug("[NO CACHE] [PREVIEW] for query", query)
return doCall()
}