stack trace in logging toml
This commit is contained in:
@@ -68,6 +68,7 @@ exclude = ["console"]
|
||||
| `format` | `"pretty"`, `"bare"`, `"json"` | How output is formatted |
|
||||
| `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 `"*"`) |
|
||||
| `stack` | array of channel names | Channels that capture a stack trace |
|
||||
| `path` | file path | Output file (file sinks only) |
|
||||
|
||||
### Formats
|
||||
@@ -113,33 +114,33 @@ File sinks write one JSON-encoded record per line. Console sinks format the reco
|
||||
|
||||
## Stack Traces
|
||||
|
||||
Set `stack = true` at the top level of `.cell/log.toml` to capture a full call stack with every log record.
|
||||
Add a `stack` field to a sink to capture a full call stack for specific channels. The value is an array of channel names.
|
||||
|
||||
```toml
|
||||
stack = true
|
||||
|
||||
[sink.terminal]
|
||||
type = "console"
|
||||
format = "pretty"
|
||||
format = "bare"
|
||||
channels = ["console", "error"]
|
||||
stack = ["error"]
|
||||
```
|
||||
|
||||
With pretty format, the stack is printed indented below each message:
|
||||
Only channels listed in `stack` get stack traces. Other channels on the same sink print without one:
|
||||
|
||||
```
|
||||
[a3f12] [error] server.ce:42 connection failed
|
||||
[a3f12] server started
|
||||
[a3f12] connection failed
|
||||
at handle_request (server.ce:42:3)
|
||||
at process (router.ce:18:5)
|
||||
at main (main.ce:5:1)
|
||||
```
|
||||
|
||||
With JSON format, a `stack` array is added to the record:
|
||||
With JSON format, a `stack` array is added to the record for channels that have stack capture enabled:
|
||||
|
||||
```json
|
||||
{"actor_id":"a3f12...","channel":"error","event":"connection failed","source":{"file":"server.ce","line":42,"col":3,"fn":"handle_request"},"stack":[{"fn":"handle_request","file":"server.ce","line":42,"col":3},{"fn":"process","file":"router.ce","line":18,"col":5},{"fn":"main","file":"main.ce","line":5,"col":1}]}
|
||||
```
|
||||
|
||||
When `stack` is not set or `false`, no stack is captured and the `stack` field is omitted from records. Capturing stacks adds overhead — enable it for debugging, not production.
|
||||
Channels without `stack` configuration produce no stack field. Capturing stacks adds overhead — enable it for debugging, not production.
|
||||
|
||||
## CLI
|
||||
|
||||
|
||||
Reference in New Issue
Block a user