Logger.getEffectiveThreshold() currently uses a truthiness check:
if(this.threshold){returnthis.threshold}
Since LogLevel.ALL = 0, an explicit threshold of LogLevel.ALL is treated as “unset”. That means a child logger cannot override a stricter parent threshold back down to ALL.
Reproduction
constparent=newLogger("parent",undefined,LogLevel.WARN)constchild=newLogger("child",parent,LogLevel.ALL)constappender={threshold: LogLevel.ALL,messages:[]asLogMessage[],appendMessage(msg: LogMessage){this.messages.push(msg)},}child.appenders=[appender]child.info("should be logged")
Expected
child.info(...) should be logged, because the child explicitly set its threshold to LogLevel.ALL.
Actual
The child falls through to the parent threshold (WARN), so INFO is dropped.
Scope
Change Logger.getEffectiveThreshold() to use an explicit undefined/null check instead of truthiness
Add a regression test where a child logger sets LogLevel.ALL under a stricter parent threshold
Review related threshold logic for the same 0-is-falsy pattern
Notes
This is a real functional bug.
The current logger test added in PR #3 does not catch this case because it constructs a logger without a stricter parent, so the fallback path still returns LogLevel.ALL.
Related follow-up: issue #4 tracks similar truthiness cleanup in the appenders, where the current behavior is correct but fragile.
## Problem
`Logger.getEffectiveThreshold()` currently uses a truthiness check:
```ts
if (this.threshold) {
return this.threshold
}
```
Since `LogLevel.ALL = 0`, an explicit threshold of `LogLevel.ALL` is treated as “unset”. That means a child logger cannot override a stricter parent threshold back down to `ALL`.
## Reproduction
```ts
const parent = new Logger("parent", undefined, LogLevel.WARN)
const child = new Logger("child", parent, LogLevel.ALL)
const appender = {
threshold: LogLevel.ALL,
messages: [] as LogMessage[],
appendMessage(msg: LogMessage) {
this.messages.push(msg)
},
}
child.appenders = [appender]
child.info("should be logged")
```
### Expected
`child.info(...)` should be logged, because the child explicitly set its threshold to `LogLevel.ALL`.
### Actual
The child falls through to the parent threshold (`WARN`), so `INFO` is dropped.
## Scope
- [ ] Change `Logger.getEffectiveThreshold()` to use an explicit `undefined`/`null` check instead of truthiness
- [ ] Add a regression test where a child logger sets `LogLevel.ALL` under a stricter parent threshold
- [ ] Review related threshold logic for the same `0`-is-falsy pattern
## Notes
- This is a real functional bug.
- The current logger test added in PR #3 does **not** catch this case because it constructs a logger without a stricter parent, so the fallback path still returns `LogLevel.ALL`.
- Related follow-up: issue #4 tracks similar truthiness cleanup in the appenders, where the current behavior is correct but fragile.
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
Logger.getEffectiveThreshold()currently uses a truthiness check:Since
LogLevel.ALL = 0, an explicit threshold ofLogLevel.ALLis treated as “unset”. That means a child logger cannot override a stricter parent threshold back down toALL.Reproduction
Expected
child.info(...)should be logged, because the child explicitly set its threshold toLogLevel.ALL.Actual
The child falls through to the parent threshold (
WARN), soINFOis dropped.Scope
Logger.getEffectiveThreshold()to use an explicitundefined/nullcheck instead of truthinessLogLevel.ALLunder a stricter parent threshold0-is-falsy patternNotes
LogLevel.ALL.