Skip to content

Commit

Permalink
add date to logs (#134)
Browse files Browse the repository at this point in the history
* add date to logs

* nits
  • Loading branch information
rajranjan0608 committed Jan 8, 2024
1 parent abb21a6 commit ddc799d
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 4 deletions.
6 changes: 5 additions & 1 deletion CouponService/couponService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
}))
}
})

Expand Down
12 changes: 10 additions & 2 deletions middlewares/verifyCaptcha.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
1 change: 1 addition & 0 deletions server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
6 changes: 5 additions & 1 deletion utils/mainnetBalanceCheck.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit ddc799d

Please sign in to comment.