Skip to content

feat: use structured logging via client.app.log() per OpenCode plugin best practices (#77)#78

Merged
tryweb merged 2 commits intomainfrom
feat/issue-77-structured-logging
Apr 9, 2026
Merged

feat: use structured logging via client.app.log() per OpenCode plugin best practices (#77)#78
tryweb merged 2 commits intomainfrom
feat/issue-77-structured-logging

Conversation

@tryweb
Copy link
Copy Markdown
Owner

@tryweb tryweb commented Apr 9, 2026

Summary

  • Add src/logger.ts as a wrapper around client.app.log() with console fallback for early-boot messages
  • Replace console.warn/console.info with structured log() in index.ts, embedder.ts, memory.ts
  • Log plugin version on initialization

Changes

New file

  • src/logger.ts - Structured logging module that:
    • Uses client.app.log() when SDK client is available
    • Falls back to console.* when client is not yet initialized (early boot) or API fails
    • Always includes service: "lancedb-opencode-pro" for log filtering

Modified files

  • src/index.ts - Replaced 6 console.warn/info calls with log(), added version logging on init
  • src/embedder.ts - Replaced 5 console.warn/info calls with log()
  • src/tools/memory.ts - Replaced 1 console.info call with log()

Not included (out of scope)

  • src/store.ts and src/config.ts internal infrastructure logs ([store], [config] prefixes) - these are internal system logs, not plugin API usage

Verification

  • ✅ TypeScript typecheck passes
  • ✅ Foundation tests: 31 pass / 0 fail
  • ✅ Regression tests: 31 pass / 1 fail (pre-existing, unrelated)
  • ✅ Retrieval tests: 2 pass / 0 fail

Developer added 2 commits April 9, 2026 08:01
… best practices (#77)

- Add src/logger.ts: wrapper around client.app.log() with console fallback
- Replace console.warn/info with structured log() in index.ts, embedder.ts, memory.ts
- Log plugin version on initialization

Implements Issue #77 suggestions:
- Structured logging (client.app.log instead of console.warn/info)
- Plugin version info on init
…eanup

- Allow passing undefined to explicitly clear env vars
- Fix test isolation issue where host LANCEDB_OPENCODE_PRO_EMBEDDING_MODEL
  was leaking into test environment causing false pass
- Clear both EMBEDDING_MODEL and OPENAI_MODEL in affected test
@tryweb tryweb merged commit e6d9436 into main Apr 9, 2026
9 checks passed
@tryweb tryweb deleted the feat/issue-77-structured-logging branch April 9, 2026 00:14
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