The open source coding agent.
TypeScript
docs: add logging best practices for plugin authors (#6833)
Matt Silverlock8aa56dc01d0b
diff --git a/packages/web/src/content/docs/plugins.mdx b/packages/web/src/content/docs/plugins.mdxindex 59a7010833d..11ecfcfedc6 100644--- a/packages/web/src/content/docs/plugins.mdx+++ b/packages/web/src/content/docs/plugins.mdx@@ -288,6 +288,25 @@ Your custom tools will be available to opencode alongside built-in tools.---+### Logging++Use `client.app.log()` instead of `console.log` for structured logging:++```ts title=".opencode/plugin/my-plugin.ts"+export const MyPlugin = async ({ client }) => {+ await client.app.log({+ service: "my-plugin",+ level: "info",+ message: "Plugin initialized",+ extra: { foo: "bar" }+ })+}+```++Levels: `debug`, `info`, `warn`, `error`. See [SDK documentation](https://opencode.ai/docs/sdk) for details.++---+### Compaction hooksCustomize the context included when a session is compacted: