Skip to content

feat(logging): honor OpenCode's host logLevel + configurable level for standalone runtime#17

Merged
stephane-segning merged 3 commits into
mainfrom
claude/great-sanderson-07cbf5
May 26, 2026
Merged

feat(logging): honor OpenCode's host logLevel + configurable level for standalone runtime#17
stephane-segning merged 3 commits into
mainfrom
claude/great-sanderson-07cbf5

Conversation

@stephane-segning
Copy link
Copy Markdown
Contributor

Summary

  • Inside OpenCode, the plugin now reads the host's top-level config.logLevel ("DEBUG" | "INFO" | "WARN" | "ERROR") so a single host-level setting drives both the console output and the forwarded client.app.log records — no separate plugin knob to keep in sync.
  • Standalone consumers of OAuth2ModelSyncPlugin (anyone using the runtime without the OpenCode shell) can pass logLevel via OAuth2ModelSyncConfigInput; values are validated against "debug" | "info" | "warn" | "error" and default to "info".
  • The OpenCode logger gates by a live level reference, so the threshold from the config hook takes effect on the very first emitted record.

Why

Previous behavior hardcoded "info", so debug-level OAuth/discovery traces were invisible even when the host CLI was in debug mode. The first iteration added a dedicated pluginConfig.oauth2ModelSync.logLevel knob — but that meant two log-level settings that could disagree, and a confusing UX where bumping OpenCode's own level didn't reach the plugin. Deferring to the host's config.logLevel resolves both problems while keeping a standalone-friendly escape hatch.

Notes for reviewers

  • fromOpenCodeLogLevel is intentionally permissive: it returns undefined (rather than throwing) on unknown values so the host owns validation of its own field. The plugin then falls back to DEFAULT_LOG_LEVEL ("info").
  • createOpenCodeLogger now bypasses createJsonConsoleLogger's internal filter and gates through a getMinLevel() closure so level changes from the config hook apply immediately, including the first call.
  • README updated: the new behavior is documented as a note under the pluginConfig.oauth2ModelSync table rather than as a separate field row.

Test plan

  • pnpm --filter @vymalo/opencode-oauth2 typecheck — clean
  • pnpm --filter @vymalo/opencode-oauth2 test — 101 passed (7 new: 3 covering standalone logLevel validation, 1 OpenCode-host-logLevel smoke test, 3 fromOpenCodeLogLevel unit tests)
  • biome check on touched files — clean
  • Manual smoke: set logLevel: "DEBUG" in opencode.json, run a sync, confirm oauth_* debug events appear

🤖 Generated with Claude Code

…r standalone runtime

Defaults to "info". Inside OpenCode the plugin now reads the host's
top-level `config.logLevel` ("DEBUG"|"INFO"|"WARN"|"ERROR") so a single
host-level setting drives both console output and forwarded `app.log`
records — no separate plugin knob to keep in sync. Standalone consumers
of OAuth2ModelSyncPlugin can still pass `logLevel` via the runtime
config (validated, defaults to "info").

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Copy link
Copy Markdown

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request integrates the host's top-level logLevel configuration into the opencode-oauth2 plugin, ensuring that plugin logs honor the host's log level settings. Feedback on these changes highlights two main improvements: first, updating the currentLogLevel before calling collectManagedProviders so that initial configuration parsing logs are filtered correctly; and second, exporting and reusing the LOG_LEVEL_PRIORITY map from logging.ts instead of duplicating it in opencode.ts to maintain a single source of truth.

Comment thread packages/opencode-oauth2/src/opencode.ts Outdated
Comment thread packages/opencode-oauth2/src/opencode.ts Outdated
stephane-segning and others added 2 commits May 26, 2026 14:32
… priority map

Two review fixes from the PR:
- Update `currentLogLevel` BEFORE calling `collectManagedProviders` so that
  warnings emitted during config parsing (plugin_config_server_invalid /
  plugin_config_server_missing_fields) are filtered against the user's
  chosen threshold rather than the bootstrap default.
- Export `LOG_LEVEL_PRIORITY` from logging.ts and drop the duplicate copy
  in opencode.ts — single source of truth.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Minor bump (pre-1.0) for the logLevel feature: plugin now honors
OpenCode's host logLevel, and standalone runtime gains a validated
`logLevel` field in OAuth2ModelSyncConfigInput.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@stephane-segning stephane-segning merged commit c182f87 into main May 26, 2026
3 checks passed
@stephane-segning stephane-segning deleted the claude/great-sanderson-07cbf5 branch May 26, 2026 13:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant