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 { notFound } from "next/navigation"
|
||||
|
||||
import { myStay } from "@scandic-hotels/common/constants/routes/myStay"
|
||||
import { logger } from "@scandic-hotels/common/logger"
|
||||
import { BookingErrorCodeEnum } from "@scandic-hotels/trpc/enums/bookingErrorCode"
|
||||
|
||||
import { PaymentCallbackStatusEnum } from "@/constants/booking"
|
||||
@@ -25,7 +26,7 @@ export default async function GuaranteePaymentCallbackPage(
|
||||
) {
|
||||
const searchParams = await props.searchParams
|
||||
const params = await props.params
|
||||
console.log(`[gla-payment-callback] callback started`)
|
||||
logger.debug(`[gla-payment-callback] callback started`)
|
||||
const lang = params.lang
|
||||
const status = searchParams.status
|
||||
const confirmationNumber = searchParams.confirmationNumber
|
||||
@@ -49,7 +50,7 @@ export default async function GuaranteePaymentCallbackPage(
|
||||
/>
|
||||
)
|
||||
}
|
||||
console.log(`[gla-payment-callback] redirecting to: ${myStayUrl}`)
|
||||
logger.debug(`[gla-payment-callback] redirecting to: ${myStayUrl}`)
|
||||
return <TrackGuarantee status={status} redirectUrl={myStayUrl} />
|
||||
}
|
||||
|
||||
@@ -76,7 +77,7 @@ export default async function GuaranteePaymentCallbackPage(
|
||||
: BookingErrorCodeEnum.TransactionFailed
|
||||
)
|
||||
} catch {
|
||||
console.error(
|
||||
logger.error(
|
||||
`[gla-payment-callback] failed to get booking status for ${confirmationNumber}, status: ${status}`
|
||||
)
|
||||
if (status === PaymentCallbackStatusEnum.Cancel) {
|
||||
@@ -86,7 +87,10 @@ export default async function GuaranteePaymentCallbackPage(
|
||||
errorMessage = `Failed to get booking status for ${confirmationNumber}, status: ${status}`
|
||||
}
|
||||
}
|
||||
console.log(errorMessage)
|
||||
|
||||
if (errorMessage) {
|
||||
logger.error(errorMessage)
|
||||
}
|
||||
|
||||
if (isAncillaryFlow) {
|
||||
searchObject.set("ancillary", "ancillary")
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import { notFound } from "next/navigation"
|
||||
|
||||
import { logger } from "@scandic-hotels/common/logger"
|
||||
import { getServiceToken } from "@scandic-hotels/common/tokenManager"
|
||||
import { BookingErrorCodeEnum } from "@scandic-hotels/trpc/enums/bookingErrorCode"
|
||||
import { getBooking } from "@scandic-hotels/trpc/routers/booking/utils"
|
||||
@@ -31,13 +32,13 @@ export default async function PaymentCallbackPage(
|
||||
) {
|
||||
const searchParams = await props.searchParams
|
||||
const params = await props.params
|
||||
console.log(`[payment-callback] callback started`)
|
||||
logger.debug(`[payment-callback] callback started`)
|
||||
const lang = params.lang
|
||||
const status = searchParams.status
|
||||
const confirmationNumber = searchParams.confirmationNumber
|
||||
|
||||
if (!status || !confirmationNumber) {
|
||||
console.error(
|
||||
logger.error(
|
||||
`[payment-callback] missing status or confirmationNumber in search params`
|
||||
)
|
||||
notFound()
|
||||
@@ -71,7 +72,7 @@ export default async function PaymentCallbackPage(
|
||||
}
|
||||
|
||||
if (!token) {
|
||||
console.error(
|
||||
logger.error(
|
||||
`[payment-callback] no token found for user, cannot fetch booking`
|
||||
)
|
||||
notFound()
|
||||
@@ -89,7 +90,7 @@ export default async function PaymentCallbackPage(
|
||||
const expire = Math.floor(Date.now() / 1000) + 60
|
||||
const sig = encrypt(expire.toString())
|
||||
const confirmationUrl = `${bookingConfirmation(lang)}?RefId=${encodeURIComponent(refId)}`
|
||||
console.log(
|
||||
logger.debug(
|
||||
`[payment-callback] rendering success callback with confirmation number: ${confirmationNumber}`
|
||||
)
|
||||
|
||||
@@ -126,7 +127,7 @@ export default async function PaymentCallbackPage(
|
||||
: BookingErrorCodeEnum.TransactionFailed
|
||||
)
|
||||
} catch {
|
||||
console.error(
|
||||
logger.error(
|
||||
`[payment-callback] failed to get booking status for ${confirmationNumber}, status: ${status}`
|
||||
)
|
||||
searchObject.set("errorCode", BookingErrorCodeEnum.TransactionFailed)
|
||||
@@ -135,7 +136,7 @@ export default async function PaymentCallbackPage(
|
||||
}
|
||||
|
||||
if (status === PaymentCallbackStatusEnum.Error) {
|
||||
console.error(
|
||||
logger.error(
|
||||
`[payment-callback] error status received for ${confirmationNumber}, status: ${status}`
|
||||
)
|
||||
searchObject.set("errorCode", BookingErrorCodeEnum.TransactionFailed)
|
||||
|
||||
Reference in New Issue
Block a user