From ddc799dd1c71b6b4e280196838ef711b09e25db8 Mon Sep 17 00:00:00 2001 From: Raj Ranjan Date: Mon, 8 Jan 2024 21:28:40 +0530 Subject: [PATCH] add date to logs (#134) * add date to logs * nits --- CouponService/couponService.ts | 6 +++++- middlewares/verifyCaptcha.ts | 12 ++++++++++-- server.ts | 1 + utils/mainnetBalanceCheck.ts | 6 +++++- 4 files changed, 21 insertions(+), 4 deletions(-) diff --git a/CouponService/couponService.ts b/CouponService/couponService.ts index 984f87e..13ab96d 100644 --- a/CouponService/couponService.ts +++ b/CouponService/couponService.ts @@ -87,7 +87,11 @@ export class CouponService { this.coupons.set(coupon.id, coupon) } } else { - console.log("fetched invalid coupon data:", item) + console.log(JSON.stringify({ + date: new Date(), + type: 'InvalidCouponFetched', + item + })) } }) diff --git a/middlewares/verifyCaptcha.ts b/middlewares/verifyCaptcha.ts index 91d0c82..0f24693 100644 --- a/middlewares/verifyCaptcha.ts +++ b/middlewares/verifyCaptcha.ts @@ -25,7 +25,11 @@ export class VerifyCaptcha { return r }) } catch (err: any) { - console.log("Recaptcha V2 error:", err?.message) + console.log(JSON.stringify({ + date: new Date(), + type: 'RecaptchaV2Error', + item: err?.message + })) } const data = response?.data @@ -45,7 +49,11 @@ export class VerifyCaptcha { try { response = await axios.post(URL) } catch(err: any){ - console.log("Recaptcha V3 error:", err?.message) + console.log(JSON.stringify({ + date: new Date(), + type: 'RecaptchaV3Error', + item: err?.message + })) } const data = response?.data diff --git a/server.ts b/server.ts index a8e7ba6..5749ced 100644 --- a/server.ts +++ b/server.ts @@ -165,6 +165,7 @@ router.post('/sendToken', captcha.middleware, async (req: any, res: any) => { // logging requests (if enabled) DEBUG && console.log(JSON.stringify({ + date: new Date(), type: "NewFaucetRequest", faucetConfigId, address, diff --git a/utils/mainnetBalanceCheck.ts b/utils/mainnetBalanceCheck.ts index 643edb9..7254c87 100644 --- a/utils/mainnetBalanceCheck.ts +++ b/utils/mainnetBalanceCheck.ts @@ -14,7 +14,11 @@ export async function checkMainnetBalance(rpc: string, address: string, threshol return {isValid: true, balance} } } catch(err) { - console.error('ERROR: checkMainnetBalance', err) + console.error(JSON.stringify({ + date: new Date(), + type: 'MainnetBalanceCheckError', + item: err + })) return response } return response