Fix LogLevel.ALL threshold truthiness checks #4
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
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."