Skip to content

Commit 6b40d46

Browse files
authored
✨ tweak: add redis connection logging
1 parent 4e6c0d3 commit 6b40d46

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

src/events/database.js

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
const Redis = require("ioredis");
2+
3+
const redis = new Redis(REDIS_SERVER_URL);
4+
5+
// log connection
6+
redis.on("connect", () => {
7+
console.log(`[${serverTime()}][log]: Successfully connected to Redis!`);
8+
});
9+
redis.on("reconnecting", () =>{
10+
console.log(`[${serverTime()}][log]: Reconnecting to Redis...`);
11+
});
12+
redis.on("ready", () => {
13+
console.log(`[${serverTime()}][log]: Redis is ready!`);
14+
});
15+
redis.on("error", (err) => () => {
16+
console.log(`[${serverTime()}][error]: Redis Error: ${err}`);
17+
});

0 commit comments

Comments
 (0)