Skip to content

Commit

Permalink
✨ tweak: add redis connection logging
Browse files Browse the repository at this point in the history
  • Loading branch information
warengonzaga authored May 8, 2024
1 parent 4e6c0d3 commit 6b40d46
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions src/events/database.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
const Redis = require("ioredis");

const redis = new Redis(REDIS_SERVER_URL);

// log connection
redis.on("connect", () => {
console.log(`[${serverTime()}][log]: Successfully connected to Redis!`);
});
redis.on("reconnecting", () =>{
console.log(`[${serverTime()}][log]: Reconnecting to Redis...`);
});
redis.on("ready", () => {
console.log(`[${serverTime()}][log]: Redis is ready!`);
});
redis.on("error", (err) => () => {
console.log(`[${serverTime()}][error]: Redis Error: ${err}`);
});

0 comments on commit 6b40d46

Please sign in to comment.