Skip to content

Commit 7327b48

Browse files
authored
Merge pull request #38 from trieb-work/fix-logging
fix: logging
2 parents 035061e + 28af595 commit 7327b48

File tree

1 file changed

+15
-12
lines changed

1 file changed

+15
-12
lines changed

src/RedisStringsHandler.ts

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -30,18 +30,21 @@ export function redisErrorHandler<T extends Promise<unknown>>(
3030
}) as T;
3131
}
3232

33-
// This is a test to check if the event loop is lagging. If it lags, increase CPU of container
34-
setInterval(() => {
35-
const start = performance.now();
36-
setImmediate(() => {
37-
const duration = performance.now() - start;
38-
if (duration > 100) {
39-
console.warn(
40-
`RedisStringsHandler detected an event loop lag of: ${duration.toFixed(2)}ms`,
41-
);
42-
}
43-
});
44-
}, 10);
33+
if (process.env.DEBUG_CACHE_HANDLER) {
34+
// This is a test to check if the event loop is lagging. If it lags, increase CPU of container
35+
setInterval(() => {
36+
const start = performance.now();
37+
setImmediate(() => {
38+
const duration = performance.now() - start;
39+
if (duration > 100) {
40+
debug(
41+
'yellow',
42+
`RedisStringsHandler detected an event loop lag of: ${duration.toFixed(2)}ms. If your container is hosted in a cloud provider with container suspension this is normal. If not you should increase the CPU of your container.`,
43+
);
44+
}
45+
});
46+
}, 500);
47+
}
4548

4649
export type CreateRedisStringsHandlerOptions = {
4750
/** Redis redisUrl to use.

0 commit comments

Comments
 (0)