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:
@@ -1,6 +1,7 @@
|
||||
import { Lang } from "@scandic-hotels/common/constants/language"
|
||||
import { getCacheClient } from "@scandic-hotels/common/dataCache"
|
||||
import { dt } from "@scandic-hotels/common/dt"
|
||||
import { createLogger } from "@scandic-hotels/common/logger/createLogger"
|
||||
import { createCounter } from "@scandic-hotels/common/telemetry"
|
||||
|
||||
import { env } from "../../../env/server"
|
||||
@@ -79,6 +80,8 @@ import type {
|
||||
import type { CityLocation } from "../../types/locations"
|
||||
import type { Room } from "../../types/room"
|
||||
|
||||
const hotelQueryLogger = createLogger("hotelQueryRouter")
|
||||
|
||||
export const hotelQueryRouter = router({
|
||||
availability: router({
|
||||
hotelsByCity: safeProtectedServiceProcedure
|
||||
@@ -189,8 +192,10 @@ export const hotelQueryRouter = router({
|
||||
const selectedRooms = []
|
||||
for (const [idx, room] of availability.entries()) {
|
||||
if (!room || "error" in room) {
|
||||
console.info(`Availability failed: ${room.error}`)
|
||||
console.error(room.details)
|
||||
hotelQueryLogger.error(
|
||||
`Availability failed: ${room.error}`,
|
||||
room.details
|
||||
)
|
||||
selectedRooms.push(null)
|
||||
continue
|
||||
}
|
||||
@@ -203,7 +208,7 @@ export const hotelQueryRouter = router({
|
||||
ctx.userPoints
|
||||
)
|
||||
if (!selected) {
|
||||
console.error("Unable to find selected room")
|
||||
hotelQueryLogger.error("Unable to find selected room")
|
||||
selectedRooms.push(null)
|
||||
continue
|
||||
}
|
||||
@@ -347,7 +352,7 @@ export const hotelQueryRouter = router({
|
||||
)
|
||||
|
||||
if (!selected) {
|
||||
console.error("Unable to find selected room")
|
||||
hotelQueryLogger.error("Unable to find selected room")
|
||||
return null
|
||||
}
|
||||
|
||||
@@ -895,13 +900,13 @@ export const hotelQueryRouter = router({
|
||||
const data = await response.json()
|
||||
|
||||
if (data.status !== "OK") {
|
||||
console.error(`Geocode error: ${data.status}`)
|
||||
hotelQueryLogger.error(`Geocode error: ${data.status}`)
|
||||
return null
|
||||
}
|
||||
|
||||
const location = data.results[0]?.geometry?.location
|
||||
if (!location) {
|
||||
console.error("No location found in geocode response")
|
||||
hotelQueryLogger.error("No location found in geocode response")
|
||||
return null
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user