#9461: refactor(cli): replace console.warn with SubsystemLogger in health.ts
commands
agents
size: XS
Cluster:
Refactor Console Logging in Agents
## Description
Refactors `src/commands/health.ts` to use the standardized `SubsystemLogger` for debug output instead of direct `console.warn` calls.
## Motivation
This aligns the health command with the project's logging standards, ensuring debug messages are correctly controlled by the logging subsystem configuration.
## Changes
- Replaced `console.warn` with `log.warn` inside `debugHealth`.
- Initialized `createSubsystemLogger("commands/health")`.
- Preserved `OPENCLAW_DEBUG_HEALTH` env var check.
## Tests
- Verified with `npm run build` (Passed).
<!-- greptile_comment -->
<h2>Greptile Overview</h2>
<h3>Greptile Summary</h3>
This PR standardizes warning/debug output by replacing `console.warn` with `SubsystemLogger` in:
- `src/commands/health.ts` (health command debug output)
- `src/agents/compaction.ts` (summarization fallback warnings)
It also removes an unused import from `src/cron/isolated-agent/run.ts` as part of prior related logging/thinking-level cleanup.
Overall this aligns CLI/agent output with the repo’s logging subsystem so warnings can be controlled by configuration rather than always printing to stderr.
<h3>Confidence Score: 3/5</h3>
- This PR is close to mergeable but currently breaks typechecking and adds a debug-only crash case.
- Confidence reduced due to a definite missing type import in `health.ts` and a new runtime throw path when debug logging is enabled (JSON.stringify on unknown args). Other changes look consistent with existing SubsystemLogger usage patterns.
- src/commands/health.ts
<!-- greptile_other_comments_section -->
**Context used:**
- Context from `dashboard` - CLAUDE.md ([source](https://app.greptile.com/review/custom-context?memory=fd949e91-5c3a-4ab5-90a1-cbe184fd6ce8))
- Context from `dashboard` - AGENTS.md ([source](https://app.greptile.com/review/custom-context?memory=0d0c8278-ef8e-4d6c-ab21-f5527e322f13))
<!-- /greptile_comment -->
Most Similar PRs
#9974: refactor(agents): replace console.warn with SubsystemLogger in comp...
by dinakars777 · 2026-02-05
87.8%
#9425: refactor(agents): replace console.warn with SubsystemLogger in comp...
by dinakars777 · 2026-02-05
84.9%
#23669: refactor(logging): migrate node-host and tailscale console calls to...
by kevinWangSheng · 2026-02-22
79.7%
#11281: fix(logging): prevent subsystem loggers from bypassing file log lev...
by janckerchen · 2026-02-07
79.7%
#9990: refactor(agents): replace console.warn with SubsystemLogger in veni...
by dinakars777 · 2026-02-06
77.1%
#7316: fix: /chat dashboard performance
by felipcsousa · 2026-02-02
76.9%
#15852: fix: pass agentId when resolving IRC session paths
by MisterGuy420 · 2026-02-14
76.4%
#7085: test: skip flaky workspace-paths & safe-bins tests on non-Linux/CI ...
by ThinkIbrokeIt · 2026-02-02
76.0%
#11549: lint: add no-console rule and migrate 5 files to structured logger
by vaibhavtupe · 2026-02-08
75.9%
#11153: refactor(hooks): replace console.warn/error with subsystem logger
by hclsys · 2026-02-07
75.9%