doc stop, json, log

This commit is contained in:
2026-02-18 10:18:28 -06:00
parent 76c482b84e
commit bd53089578
3 changed files with 20 additions and 4 deletions

View File

@@ -111,6 +111,18 @@ $stop() // stop self
$stop(child) // stop a child actor
```
**Important:** `$stop()` does not halt execution immediately. Code after the call continues running in the current turn — it only prevents the actor from receiving future messages. Structure your code so that nothing runs after `$stop()`, or use `return` to exit the current function first.
```javascript
// Wrong — code after $stop() still runs
if (done) $stop()
do_more_work() // this still executes!
// Right — return after $stop()
if (done) { $stop(); return }
do_more_work()
```
### $start(callback, program)
Start a new child actor from a script. The callback receives lifecycle events:

View File

@@ -15,10 +15,14 @@ var json = use('json')
### json.encode(value, space, replacer, whitelist)
Convert a value to JSON text.
Convert a value to JSON text. With no `space` argument, output is pretty-printed with 1-space indent. Pass `false` or `0` for compact single-line output.
```javascript
json.encode({a: 1, b: 2})
// '{ "a": 1, "b": 2 }'
// Compact (no whitespace)
json.encode({a: 1, b: 2}, false)
// '{"a":1,"b":2}'
// Pretty print with 2-space indent
@@ -32,7 +36,7 @@ json.encode({a: 1, b: 2}, 2)
**Parameters:**
- **value** — the value to encode
- **space** — indentation (number of spaces or string)
- **space** — indentation: number of spaces, string, or `false`/`0` for compact output. Default is pretty-printed.
- **replacer** — function to transform values
- **whitelist** — array of keys to include

View File

@@ -66,7 +66,7 @@ exclude = ["console"]
|-------|--------|-------------|
| `type` | `"console"`, `"file"` | Where output goes |
| `format` | `"pretty"`, `"bare"`, `"json"` | How output is formatted |
| `channels` | array of names, or `["*"]` | Which channels this sink receives |
| `channels` | array of names, or `["*"]` | Which channels this sink receives. Quote `'*'` on the CLI to prevent shell glob expansion. |
| `exclude` | array of names | Channels to skip (useful with `"*"`) |
| `path` | file path | Output file (file sinks only) |
@@ -118,7 +118,7 @@ The `pit log` command manages sinks and reads log files. See [CLI — pit log](/
```bash
pit log list # show sinks
pit log add terminal console --format=bare --channels=console
pit log add dump file .cell/logs/dump.jsonl --channels='*' --exclude=console
pit log add dump file .cell/logs/dump.jsonl '--channels=*' --exclude=console
pit log remove terminal
pit log read dump --lines=20 --channel=error
pit log tail dump