fix(logging): default production log level to info with an opt-in debug toggle (#609)#620
Conversation
…ug toggle (#609) Production installs logged at DEBUG unconditionally, flooding the .log and leaking internal detail. Default to info; add a `debugLogging` global setting (PI: Common Settings -> Diagnostics -> "Enable debug logging") that re-enables DEBUG at runtime without a rebuild or reinstall. - deck-core: add `debugLogging` to GlobalSettingsSchema (default false) - logger: createConsoleLogger accepts a live level resolver (LogLevelSource) - Elgato: setLevel("info") default, re-applied from debugLogging on every global-settings change (single streamDeck.logger file-writer gate; the scoped wrapper keeps forwarding debug so a runtime flip surfaces it) - Mirabox: adapter holds a runtime-mutable level its loggers read live; the Stream Dock host discards plugin stdout, so loggers also tee to <plugin>/log/<YYYY.M.D>.log (FileSink + withFileSink) - that file is what the toggle captures for support - PI: shared "Enable debug logging" checkbox in global-common-settings - tests: schema defaults/coercion, console-logger live resolver, mirabox adapter live toggle, file-logger - docs: logging.md, plugin-structure.md, global-settings.md, deck-adapter-mirabox CLAUDE.md, website troubleshooting Closes #609
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
✅ Files skipped from review due to trivial changes (1)
📝 WalkthroughWalkthroughAdds an opt-in ChangesRuntime-configurable debug logging with opt-in toggle
Sequence DiagramsequenceDiagram
participant PI as PropertyInspector
participant Plugin as PluginStartup
participant Adapter as VSDPlatformAdapter
participant Logger as createConsoleLogger
participant File as FileSink
PI->>Plugin: toggle debugLogging
Plugin->>Adapter: setLogLevel(debug ? Debug : Info)
Plugin->>Logger: create logger(scope) via shared resolver
Logger->>Adapter: call level() resolver on each log
Adapter->>File: write if level permits (withFileSink)
Estimated code review effort🎯 4 (Complex) | ⏱️ ~45 minutes Suggested labels
Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In @.claude/rules/global-settings.md:
- Line 127: The documentation line for the global setting uses
z.boolean().default(false) but the intended contract accepts both boolean and
string inputs; update the doc to reflect the coercing schema (e.g., use Zod's
boolean coercion such as z.coerce.boolean() or a z.preprocess that converts
string "true"/"false" to booleans) and show the default(false) behavior,
referencing the debugLogging schema name and the existing
z.boolean().default(false) snippet so readers know to replace that exact token
with the coercing variant.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 14649f69-9f8b-4716-91fe-388d1ff50eb4
📒 Files selected for processing (17)
.claude/rules/global-settings.md.claude/rules/logging.md.claude/rules/plugin-structure.mdpackages/deck-adapter-mirabox/CLAUDE.mdpackages/deck-adapter-mirabox/src/adapter.log-level.test.tspackages/deck-adapter-mirabox/src/adapter.tspackages/deck-adapter-mirabox/src/file-logger.test.tspackages/deck-adapter-mirabox/src/file-logger.tspackages/deck-core/src/global-settings.test.tspackages/deck-core/src/global-settings.tspackages/deck-core/src/simhub-service.test.tspackages/iracing-plugin-mirabox/src/plugin.tspackages/iracing-plugin-stream-deck/src/plugin.tspackages/logger/src/index.test.tspackages/logger/src/index.tspackages/pi-components/partials/global-common-settings.ejspackages/website/src/content/docs/docs/getting-started/troubleshooting.md
CodeRabbit (#620): the global-settings.md schema snippet showed debugLogging as z.boolean().default(false), but the field coerces the "true"/"false" strings the Property Inspector sends. Align the doc with the real coercing union so future edits don't regress parsing.
Summary
Every production install of the Elgato plugin wrote full
DEBUG-level logs (one real user's log was 2,870DEBUGlines vs 637INFOover two sessions). Debug logging should be opt-in for troubleshooting, not the default — it bloats the log, leaks internal detail, and buries real signal during support. This defaults production logging toinfoand adds an "Enable debug logging" global setting that re-enablesDEBUGat runtime, with no rebuild or reinstall.Related Issue
Closes #609
Changes
debugLoggingboolean toGlobalSettingsSchema(defaultfalse, standard string/boolean coercion).createConsoleLoggeraccepts a live level resolver (LogLevelSource = LogLevel | (() => LogLevel)) so a logger's level can change at runtime; child scopes share the resolver.iracing-plugin-stream-deck) — defaultstreamDeck.logger.setLevel("info"); applydebugLogging ? "debug" : "info"after init and on everyonGlobalSettingsChange. Gating stays at the singlestreamDeck.loggerfile-writer; thecreateSDLoggerwrapper keeps forwarding debug so a runtime flip surfaces scoped debug logs without recreating loggers.deck-adapter-mirabox+iracing-plugin-mirabox) — adapter holds a runtime-mutablelogLevel(setLogLevel) its loggers read live. Because the Stream Dock host discards plugin stdout, the adapter also tees every logger to<plugin>/log/<YYYY.M.D>.log(FileSink+withFileSink, matching the host's ownlog/convention) so the toggle produces an attachable support log.global-common-settings.ejs), so both plugins expose it.logging.md,plugin-structure.md,global-settings.md,deck-adapter-mirabox/CLAUDE.md, and websitetroubleshooting.md(per-platform log locations).Testing
pnpm build,pnpm test(145 files, 4533 tests),pnpm lint:fix,pnpm format:fix— all green.file-logger(unpadded per-day filename, append, dir creation, error-swallowing, tee + level gating + scope chaining).log/folder for our plugin; 0 iRaceDeck lines in the hostdebug.log) — this motivated the Mirabox file-logging addition.Screenshots (if applicable)
N/A — the PI adds a single checkbox under Common Settings → Diagnostics.
Checklist
pnpm test)pnpm build)pnpm lint:fix&&pnpm format:fix)Summary by CodeRabbit
New Features
Documentation