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:
@@ -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()
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user