Skip to content

feat(wallet): add injectable logger to WalletOptions#9097

Open
grypez wants to merge 2 commits into
mainfrom
grypez/wallet-init-logger
Open

feat(wallet): add injectable logger to WalletOptions#9097
grypez wants to merge 2 commits into
mainfrom
grypez/wallet-init-logger

Conversation

@grypez

@grypez grypez commented Jun 11, 2026

Copy link
Copy Markdown
Contributor

Explanation

@metamask/wallet is the shared controller-integration layer for the extension, mobile, and other clients (e.g. wallet-cli), so any value that differs between clients is an injectable WalletOptions field rather than something hardcoded.

This PR adds an optional logger?: Pick<Console, 'info'> field to WalletOptions. When provided, the initialization loop emits a [wallet] ${name}: initialized breadcrumb via logger.info immediately after each controller's init() returns, in initialization order. The field is no-op by default, so library consumers are unaffected unless they opt in.

Passing { logger: console } during a development run then produces one timestamped log line per wired controller, in order. This gives visibility into controller initialization sequence and timing — the empirical data needed to observe which messenger actions a controller calls during init() versus at runtime. Any messenger action observed before a controller's init-complete breadcrumb is a candidate for an init messenger; calls after are runtime uses.

Closes #8791.

Options

Option Extension Mobile Default (e.g. wallet-cli)
logger omit, or pass the client's logger (e.g. console) for dev diagnostics omit, or pass the client's logger omit (no output), or console during development

The default is no output, so the field has no effect on any client that does not pass it.

References

N/A

Checklist

  • I've updated the test suite for new or updated code as appropriate
  • I've updated documentation (JSDoc, Markdown, etc.) for new or updated code as appropriate
  • I've highlighted breaking changes using the "BREAKING" category above as appropriate
    • No breaking changes — the field is optional and defaults to no output.
  • I've prepared draft pull requests for clients and consumer packages to resolve any breaking changes (N/A)

🤖 Generated with Claude Code


Note

Low Risk
Optional diagnostic logging only; no change to init logic or required options when logger is omitted.

Overview
Adds an optional logger on WalletOptions (Pick<Console, 'info'>) so clients can opt into initialization diagnostics without changing default behavior.

During initialize(), after each controller's init() finishes, the wallet calls logger?.info with [wallet] ${name}: initialized in wiring order. Wallet forwards the option unchanged; JSDoc and the changelog document the hook. Tests assert ordered breadcrumbs match defaultConfigurations and that construction still works when logger is omitted.

Reviewed by Cursor Bugbot for commit f01e8f5. Bugbot is set up for automated code reviews on this repo. Configure here.

Add an optional `logger?: Pick<Console, 'info'>` field to `WalletOptions`.
When provided, `initialize()` emits a `[wallet] ${name}: initialized`
breadcrumb via `logger.info` immediately after each controller's `init()`
completes, in initialization order. The field is no-op by default, so
library consumers are unaffected.

This gives visibility into controller initialization order and timing —
the data needed to observe which messenger actions are called during
`init()` vs. at runtime, informing the init-messenger pattern decision.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@grypez grypez requested a review from a team as a code owner June 11, 2026 17:28
@grypez grypez temporarily deployed to default-branch June 11, 2026 17:29 — with GitHub Actions Inactive
The `changelog:check` CI gate requires entries to reference the current
PR rather than the issue.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@grypez grypez enabled auto-merge June 11, 2026 18:15
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.

wallet: Add injectable logger to WalletOptions for initialization diagnostics

1 participant