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:
@@ -3,6 +3,7 @@ import { createEvent } from "ics"
|
||||
import { useIntl } from "react-intl"
|
||||
|
||||
import { dt } from "@scandic-hotels/common/dt"
|
||||
import { logger } from "@scandic-hotels/common/logger"
|
||||
|
||||
import { toast } from "@/components/TempDesignSystem/Toasts"
|
||||
import useLang from "@/hooks/useLang"
|
||||
@@ -25,7 +26,7 @@ export default function AddToCalendar({
|
||||
|
||||
createEvent(event, (error, value) => {
|
||||
if (error) {
|
||||
console.error("ICS Error:", error)
|
||||
logger.error("ICS Error:", error)
|
||||
toast.error(
|
||||
intl.formatMessage({
|
||||
defaultMessage: "Failed to add to calendar",
|
||||
@@ -45,7 +46,7 @@ export default function AddToCalendar({
|
||||
URL.revokeObjectURL(url)
|
||||
})
|
||||
} catch (error) {
|
||||
console.error("Download error:", error)
|
||||
logger.error("Download error:", error)
|
||||
toast.error(
|
||||
intl.formatMessage({
|
||||
defaultMessage: "Failed to add to calendar",
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
import "client-only"
|
||||
|
||||
import { logger } from "@scandic-hotels/common/logger"
|
||||
|
||||
export const glaStorageName = "gla-storage"
|
||||
|
||||
type GlaSessionData = {
|
||||
@@ -15,7 +17,7 @@ export function readGlaFromSessionStorage(): GlaSessionData | null {
|
||||
if (!glaSessionData) return null
|
||||
return JSON.parse(glaSessionData)
|
||||
} catch (error) {
|
||||
console.error("Error reading from session storage:", error)
|
||||
logger.error("Error reading from session storage:", error)
|
||||
return null
|
||||
}
|
||||
}
|
||||
@@ -37,7 +39,7 @@ export function writeGlaToSessionStorage(
|
||||
})
|
||||
)
|
||||
} catch (error) {
|
||||
console.error("Error writing to session storage:", error)
|
||||
logger.error("Error writing to session storage:", error)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -10,6 +10,7 @@ import { useIntl } from "react-intl"
|
||||
|
||||
import { PaymentMethodEnum } from "@scandic-hotels/common/constants/paymentMethod"
|
||||
import { selectRate } from "@scandic-hotels/common/constants/routes/hotelReservation"
|
||||
import { logger } from "@scandic-hotels/common/logger"
|
||||
import Body from "@scandic-hotels/design-system/Body"
|
||||
import { Button } from "@scandic-hotels/design-system/Button"
|
||||
import Checkbox from "@scandic-hotels/design-system/Form/Checkbox"
|
||||
@@ -180,7 +181,7 @@ export default function PaymentClient({
|
||||
}
|
||||
},
|
||||
onError: (error) => {
|
||||
console.error("Error", error)
|
||||
logger.error("Booking error", error)
|
||||
handlePaymentError(error.message)
|
||||
},
|
||||
})
|
||||
@@ -195,7 +196,7 @@ export default function PaymentClient({
|
||||
setPriceChangeData(null)
|
||||
},
|
||||
onError: (error) => {
|
||||
console.error("Error", error)
|
||||
logger.error("Price change error", error)
|
||||
setPriceChangeData(null)
|
||||
handlePaymentError(error.message)
|
||||
},
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import { PaymentMethodEnum } from "@scandic-hotels/common/constants/paymentMethod"
|
||||
import { logger } from "@scandic-hotels/common/logger"
|
||||
|
||||
import type { RoomState } from "@/types/stores/enter-details"
|
||||
|
||||
@@ -63,7 +64,7 @@ export function readPaymentInfoFromSessionStorage():
|
||||
if (!paymentInfoSessionData) return undefined
|
||||
return JSON.parse(paymentInfoSessionData)
|
||||
} catch (error) {
|
||||
console.error("Error reading from session storage:", error)
|
||||
logger.error("Error reading from session storage:", error)
|
||||
return undefined
|
||||
}
|
||||
}
|
||||
@@ -81,7 +82,7 @@ export function writePaymentInfoToSessionStorage(
|
||||
})
|
||||
)
|
||||
} catch (error) {
|
||||
console.error("Error writing to session storage:", error)
|
||||
logger.error("Error writing to session storage:", error)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
import { logger } from "@scandic-hotels/common/logger"
|
||||
|
||||
import { sumPackages } from "@/components/HotelReservation/utils"
|
||||
|
||||
import type { RoomState } from "@/types/stores/enter-details"
|
||||
@@ -133,7 +135,7 @@ export function mapToPrice(rooms: RoomState[], isMember: boolean) {
|
||||
}
|
||||
}
|
||||
|
||||
console.error(room.roomRate)
|
||||
logger.error("Unknown roomRate", room.roomRate)
|
||||
throw new Error(`Unknown roomRate`)
|
||||
})
|
||||
}
|
||||
|
||||
@@ -6,6 +6,7 @@ import { FormProvider, useForm } from "react-hook-form"
|
||||
import { useIntl } from "react-intl"
|
||||
|
||||
import { myStay } from "@scandic-hotels/common/constants/routes/myStay"
|
||||
import { logger } from "@scandic-hotels/common/logger"
|
||||
import Body from "@scandic-hotels/design-system/Body"
|
||||
import Caption from "@scandic-hotels/design-system/Caption"
|
||||
import { trpc } from "@scandic-hotels/trpc/client"
|
||||
@@ -48,7 +49,7 @@ export default function FindMyBooking() {
|
||||
router.push(`${myStay[lang]}?RefId=${encodeURIComponent(result.refId)}`)
|
||||
},
|
||||
onError: (error) => {
|
||||
console.error("Failed to create ref id", error)
|
||||
logger.error("Failed to create ref id", error)
|
||||
toast.error(
|
||||
intl.formatMessage({
|
||||
defaultMessage: "Failed to submit form, please try again later.",
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
import { logger } from "@scandic-hotels/common/logger"
|
||||
|
||||
import type {
|
||||
Ancillary,
|
||||
SelectedAncillary,
|
||||
@@ -59,7 +61,7 @@ export const getAncillarySessionData = ():
|
||||
const storedData = sessionStorage.getItem(ancillarySessionKey)
|
||||
return storedData ? JSON.parse(storedData) : undefined
|
||||
} catch (error) {
|
||||
console.error("Error reading from session storage:", error)
|
||||
logger.error("Error reading from session storage:", error)
|
||||
return undefined
|
||||
}
|
||||
}
|
||||
@@ -96,7 +98,7 @@ export function setAncillarySessionData({
|
||||
})
|
||||
)
|
||||
} catch (error) {
|
||||
console.error("Error writing to session storage:", error)
|
||||
logger.error("Error writing to session storage:", error)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -4,6 +4,7 @@ import { useIntl } from "react-intl"
|
||||
|
||||
import { CurrencyEnum } from "@scandic-hotels/common/constants/currency"
|
||||
import { dt } from "@scandic-hotels/common/dt"
|
||||
import { logger } from "@scandic-hotels/common/logger"
|
||||
import Body from "@scandic-hotels/design-system/Body"
|
||||
import Caption from "@scandic-hotels/design-system/Caption"
|
||||
import { MaterialIcon } from "@scandic-hotels/design-system/Icons/MaterialIcon"
|
||||
@@ -122,7 +123,7 @@ export default function SelectedRoomPanel() {
|
||||
}
|
||||
|
||||
if (!selectedProduct) {
|
||||
console.error("Selected product is unknown")
|
||||
logger.error("Selected product is unknown")
|
||||
return null
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user