Three appender implementations use a truthiness guard for threshold checks:
if (this.threshold && msg.level < this.threshold) return;
Since LogLevel.ALL = 0 is falsy in JavaScript, the expression 0 && ... short-circuits to 0 (falsy), meaning the if block is never entered and messages pass through. This is correct behavior by accident — it works today but is fragile and misleading.
The fix is to use an explicit !== undefined check instead:
if (this.threshold !== undefined && msg.level < this.threshold) return;
Add/confirm regression test coverage for explicit LogLevel.ALL = 0 edge case (tests exist but may need tightening to actually fail on the buggy code)
Notes
This is a cleanup follow-up, not a blocker. CI is green and current behavior is correct by coincidence.
The existing tests in PR #3 already cover the ALL=0 scenario (see test/console-log-appender.test.ts "threshold of ALL (0) does not cause falsy guard to block messages") but the test comment literally acknowledges "correct behavior by accident."
Fixing the guard makes the intent explicit and prevents future bugs if the logic around the guard changes.
## Problem
Three appender implementations use a truthiness guard for threshold checks:
```
if (this.threshold && msg.level < this.threshold) return;
```
Since `LogLevel.ALL = 0` is falsy in JavaScript, the expression `0 && ...` short-circuits to `0` (falsy), meaning the `if` block is never entered and messages pass through. This is **correct behavior by accident** — it works today but is fragile and misleading.
The fix is to use an explicit `!== undefined` check instead:
```
if (this.threshold !== undefined && msg.level < this.threshold) return;
```
## Scope
- [ ] `src/console-log-appender.ts` — replace truthiness check
- [ ] `src/api-log-appender.ts` — replace truthiness check
- [ ] `src/buffer-log-appender.ts` — replace truthiness check
- [ ] Add/confirm regression test coverage for explicit `LogLevel.ALL = 0` edge case (tests exist but may need tightening to actually fail on the buggy code)
## Notes
- This is a cleanup follow-up, not a blocker. CI is green and current behavior is correct by coincidence.
- The existing tests in PR #3 already cover the ALL=0 scenario (see `test/console-log-appender.test.ts` "threshold of ALL (0) does not cause falsy guard to block messages") but the test comment literally acknowledges "correct behavior by accident."
- Fixing the guard makes the intent explicit and prevents future bugs if the logic around the guard changes.
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.
Problem
Three appender implementations use a truthiness guard for threshold checks:
Since
LogLevel.ALL = 0is falsy in JavaScript, the expression0 && ...short-circuits to0(falsy), meaning theifblock is never entered and messages pass through. This is correct behavior by accident — it works today but is fragile and misleading.The fix is to use an explicit
!== undefinedcheck instead:Scope
src/console-log-appender.ts— replace truthiness checksrc/api-log-appender.ts— replace truthiness checksrc/buffer-log-appender.ts— replace truthiness checkLogLevel.ALL = 0edge case (tests exist but may need tightening to actually fail on the buggy code)Notes
test/console-log-appender.test.ts"threshold of ALL (0) does not cause falsy guard to block messages") but the test comment literally acknowledges "correct behavior by accident."