feat(logging): honor OpenCode's host logLevel + configurable level for standalone runtime#17
Merged
Merged
Conversation
…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>
There was a problem hiding this comment.
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.
… 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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
config.logLevel("DEBUG" | "INFO" | "WARN" | "ERROR") so a single host-level setting drives both the console output and the forwardedclient.app.logrecords — no separate plugin knob to keep in sync.OAuth2ModelSyncPlugin(anyone using the runtime without the OpenCode shell) can passlogLevelviaOAuth2ModelSyncConfigInput; values are validated against"debug" | "info" | "warn" | "error"and default to"info".confighook 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 dedicatedpluginConfig.oauth2ModelSync.logLevelknob — 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'sconfig.logLevelresolves both problems while keeping a standalone-friendly escape hatch.Notes for reviewers
fromOpenCodeLogLevelis intentionally permissive: it returnsundefined(rather than throwing) on unknown values so the host owns validation of its own field. The plugin then falls back toDEFAULT_LOG_LEVEL("info").createOpenCodeLoggernow bypassescreateJsonConsoleLogger's internal filter and gates through agetMinLevel()closure so level changes from theconfighook apply immediately, including the first call.pluginConfig.oauth2ModelSynctable rather than as a separate field row.Test plan
pnpm --filter @vymalo/opencode-oauth2 typecheck— cleanpnpm --filter @vymalo/opencode-oauth2 test— 101 passed (7 new: 3 covering standalonelogLevelvalidation, 1 OpenCode-host-logLevel smoke test, 3fromOpenCodeLogLevelunit tests)biome checkon touched files — cleanlogLevel: "DEBUG"inopencode.json, run a sync, confirmoauth_*debug events appear🤖 Generated with Claude Code