You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
|`notify`|`boolean`| No | Show as a toast notification |
24
23
|`category`|`string`| No | Grouping category (e.g., `'a11y'`, `'lint'`) |
25
24
|`labels`|`string[]`| No | Tags for filtering |
@@ -28,55 +27,53 @@ The Logs system allows plugins to emit structured log entries from both the serv
28
27
|`status`|`'loading' \| 'idle'`| No | Status indicator (shows spinner when `'loading'`) |
29
28
|`id`|`string`| No | Explicit id for deduplication — re-adding with the same id updates the existing entry |
30
29
30
+
The `source` field is automatically set to `'server'` or `'client'` depending on where the log was emitted.
31
+
31
32
## Server-Side Usage
32
33
33
-
In your plugin's `devtools.setup`, use `context.logs` to emit log entries. The `add()` method returns a **handle** with `.update()` and `.dismiss()` helpers:
34
+
In your plugin's `devtools.setup`, use `context.logs` to emit log entries:
34
35
35
36
```ts
36
37
exportfunction myPlugin() {
37
38
return {
38
39
name: 'my-plugin',
39
40
devtools: {
40
-
asyncsetup(context) {
41
+
setup(context) {
41
42
// Simple log
42
-
awaitcontext.logs.add({
43
+
context.logs.add({
43
44
message: 'Plugin initialized',
44
45
level: 'info',
45
46
})
46
47
47
48
// Log with loading state, then update
48
-
const log =awaitcontext.logs.add({
49
+
const entry =context.logs.add({
50
+
id: 'my-build',
49
51
message: 'Building...',
50
52
level: 'info',
51
53
status: 'loading',
52
54
})
53
55
54
-
// Later, update via the handle
55
-
awaitlog.update({
56
+
// Later, update via update()
57
+
context.logs.update(entry.id, {
56
58
message: 'Build complete',
57
59
level: 'success',
58
60
status: 'idle',
59
61
})
60
-
61
-
// Or dismiss it
62
-
awaitlog.dismiss()
63
62
},
64
63
},
65
64
}
66
65
}
67
66
```
68
67
69
-
The `source` field is automatically set to the plugin name.
70
-
71
68
## Client-Side Usage
72
69
73
-
In dock action scripts, use `context.logs` — the same API as on the server:
70
+
In dock action scripts, use `context.logs` — an async client that communicates via RPC:
The `source` is automatically set to the dock entry id.
94
+
## Log Handle (Client-Side)
98
95
99
-
## Log Handle
100
-
101
-
`context.logs.add()` returns a `DevToolsLogHandle` with:
96
+
`context.logs.add()` on the client returns a `DevToolsLogHandle` with:
102
97
103
98
| Property/Method | Description |
104
99
|-----------------|-------------|
@@ -109,62 +104,22 @@ The `source` is automatically set to the dock entry id.
109
104
110
105
## Deduplication
111
106
112
-
When you call `context.logs.add()` with an explicit `id` that already exists, the existing entry is **updated** instead of duplicated. This is useful for logs that represent ongoing operations:
107
+
When you call `add()` with an explicit `id` that already exists, the existing entry is **updated** instead of duplicated. This is useful for logs that represent ongoing operations:
0 commit comments