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,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