summaryrefslogtreecommitdiffhomepage
path: root/packages/web/src/content/docs/plugins.mdx
diff options
context:
space:
mode:
authorMatt Silverlock <[email protected]>2026-01-04 09:22:14 -0500
committerGitHub <[email protected]>2026-01-04 08:22:14 -0600
commit8aa56dc01d0bbe3187dfddf72b6b9aa1756fa212 (patch)
tree775b3815ccee676a54e99e4eae9e9c5c9522b0b0 /packages/web/src/content/docs/plugins.mdx
parentd72d7ab510a50a58eeb5a55dd752b5a4a65e1f94 (diff)
downloadopencode-8aa56dc01d0bbe3187dfddf72b6b9aa1756fa212.tar.gz
opencode-8aa56dc01d0bbe3187dfddf72b6b9aa1756fa212.zip
docs: add logging best practices for plugin authors (#6833)
Diffstat (limited to 'packages/web/src/content/docs/plugins.mdx')
-rw-r--r--packages/web/src/content/docs/plugins.mdx19
1 files changed, 19 insertions, 0 deletions
diff --git a/packages/web/src/content/docs/plugins.mdx b/packages/web/src/content/docs/plugins.mdx
index 59a701083..11ecfcfed 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 hooks
Customize the context included when a session is compacted: