argsbarg 6.1.8 → 6.1.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +16 -1
- package/docs/README.md +1 -0
- package/docs/cli-program.md +2 -0
- package/docs/decisions.md +20 -1
- package/docs/http-server.md +3 -1
- package/docs/logging.md +149 -0
- package/examples/full-example/docs/cli-schema.json +18 -18
- package/examples/full-example/docs/cli.md +18 -18
- package/examples/full-example/docs/http.md +10 -0
- package/index.d.ts +84 -14
- package/package.json +1 -1
- package/src/builtins/http.ts +1 -1
- package/src/builtins/mcp.ts +1 -1
- package/src/core/types.ts +17 -3
- package/src/docs/http-guide.ts +10 -0
- package/src/headless/tool-call.ts +1 -1
- package/src/hooks/run.ts +7 -2
- package/src/http/server.ts +19 -1
- package/src/index.ts +2 -0
- package/src/log/ecs.test.ts +68 -2
- package/src/log/ecs.ts +109 -14
- package/src/log/emitter.test.ts +95 -0
- package/src/log/emitter.ts +74 -11
- package/src/log/trace.test.ts +60 -0
- package/src/log/trace.ts +62 -0
- package/src/runtime/cli.ts +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -7,6 +7,20 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
7
7
|
|
|
8
8
|
## [Unreleased]
|
|
9
9
|
|
|
10
|
+
## [6.1.9] - 2026-07-27
|
|
11
|
+
|
|
12
|
+
### Added
|
|
13
|
+
|
|
14
|
+
- **ECS Logging–compatible JSON logs** — default JSON output includes `ecs.version`, nested `labels`, canonical HTTP fields (`http.request.method`, `url.path`, `http.response.status_code`, `event.duration` in nanoseconds), and W3C `trace.id` / `span.id` when `traceparent` is present on HTTP requests.
|
|
15
|
+
- **`program.log.enrich`** — additive hook for custom JSON fields (cannot override ECS baseline keys).
|
|
16
|
+
- **`program.log.serialize`** — optional full-line JSON formatter that bypasses the built-in ECS formatter.
|
|
17
|
+
|
|
18
|
+
### Changed
|
|
19
|
+
|
|
20
|
+
- **HTTP trace propagation** — parses incoming `traceparent`, logs trace/span ids, and echoes an updated `traceparent` on responses.
|
|
21
|
+
- **CLI log-format help** — describes JSON as ECS Logging, not generic ECS.
|
|
22
|
+
- **Docs** — new [logging.md](logging.md) (`program.log`, `enrich`, `serialize`, examples); `http-server.md` links there.
|
|
23
|
+
|
|
10
24
|
## [6.1.8] - 2026-07-27
|
|
11
25
|
|
|
12
26
|
### Changed
|
|
@@ -865,7 +879,8 @@ const cli = { ... } satisfies CliProgram; // or : CliProgram
|
|
|
865
879
|
- Migrate schemas: rename every `children` property to **`commands`**; move positional definitions to **`CliPositional`** objects on `positionals` and strip `positional` / `argMin` / `argMax` from flag definitions under `options` (flags only carry `name`, `description`, `kind`, and optional `shortName`).
|
|
866
880
|
- Imports: use `CliPositional` where needed; replace `CliOptionDef` with `CliOption` or `CliPositional` as appropriate.
|
|
867
881
|
|
|
868
|
-
[Unreleased]: https://github.com/bdombro/bun-argsbarg/compare/v6.1.
|
|
882
|
+
[Unreleased]: https://github.com/bdombro/bun-argsbarg/compare/v6.1.9...HEAD
|
|
883
|
+
[6.1.9]: https://github.com/bdombro/bun-argsbarg/releases/tag/v6.1.9
|
|
869
884
|
[6.1.8]: https://github.com/bdombro/bun-argsbarg/releases/tag/v6.1.8
|
|
870
885
|
[6.1.7]: https://github.com/bdombro/bun-argsbarg/releases/tag/v6.1.7
|
|
871
886
|
[6.1.6]: https://github.com/bdombro/bun-argsbarg/releases/tag/v6.1.6
|
package/docs/README.md
CHANGED
|
@@ -11,6 +11,7 @@ Start here to pick the right guide.
|
|
|
11
11
|
| **JSON Schema validation** | [json-schema-subset.md](json-schema-subset.md) — Draft-07 / 2019-09 / 2020-12 (`$schema` on each schema; default Draft-07) |
|
|
12
12
|
| **Exposing MCP tools** | [mcp.md](mcp.md) — stdio server, `inputSchema`, varargs, `configure --sync` |
|
|
13
13
|
| **HTTP tool server** | [http-server.md](http-server.md) — `myapp http`, endpoints, curl examples |
|
|
14
|
+
| **Server logging** (`program.log`, `enrich`, `serialize`) | [logging.md](logging.md) — ECS JSON lines, trace headers, custom formats |
|
|
14
15
|
| **Shipping configure / agent artifacts** | [configure.md](configure.md) — Homebrew + `myapp configure --sync` |
|
|
15
16
|
| **Homebrew tap-from-repo distribution** | [distribution-homebrew.md](distribution-homebrew.md) — formula pattern, `argsbarg create` |
|
|
16
17
|
| **Bundling `myapp docs` topics** | [bundled-docs.md](bundled-docs.md) — consumer docgen vs framework docs |
|
package/docs/cli-program.md
CHANGED
|
@@ -41,6 +41,8 @@ const cli = {
|
|
|
41
41
|
|
|
42
42
|
`httpServer` and `mcpServer` are independent. Tool exposure uses the same rules (`mcpTool.enabled: false` hides from MCP and HTTP). See [http-server.md](http-server.md).
|
|
43
43
|
|
|
44
|
+
**Logging** — HTTP and MCP server logs go to stderr (JSON by default). Configure `program.log` on the program root; use **`enrich`** to add fields or **`serialize`** for a fully custom line. See **[logging.md](logging.md)**.
|
|
45
|
+
|
|
44
46
|
## Inline schema by default
|
|
45
47
|
|
|
46
48
|
ArgsBarg is **schema-first** — the program tree is the product. **Keep `CliProgram` and leaf fields inline** (`key`, `description`, `options`, `positionals`, `handler`) so a reader sees the full command contract in one place.
|
package/docs/decisions.md
CHANGED
|
@@ -37,4 +37,23 @@ Yes Zod implements some features we do custom for JSON-SCHEMA, but is opinionate
|
|
|
37
37
|
3. For uses like API pass-through, proxy, dynamic schemas, Zod may actually explode complexity for consumers.
|
|
38
38
|
4. Our TS->json-schema approach is actually easier and better in many cases
|
|
39
39
|
- Just write plain typescript, done.
|
|
40
|
-
- Better intellisense -- substantially less abstraction/inference, much better control
|
|
40
|
+
- Better intellisense -- substantially less abstraction/inference, much better control
|
|
41
|
+
|
|
42
|
+
## Structured logging (ECS Logging)
|
|
43
|
+
|
|
44
|
+
Decision: **ECS Logging–compatible NDJSON to stderr** (default), with optional `enrich` / `serialize` hooks
|
|
45
|
+
|
|
46
|
+
### Context
|
|
47
|
+
|
|
48
|
+
- HTTP/MCP servers need access logs, error logs, and trace correlation in production log pipelines
|
|
49
|
+
- Consumers may need custom fields (team labels, vendor-specific shapes) without baking proprietary formats into argsbarg core
|
|
50
|
+
- OpenTelemetry log export is out of scope for the framework runtime (no third-party observability SDK dependency)
|
|
51
|
+
|
|
52
|
+
### Rationale
|
|
53
|
+
|
|
54
|
+
1. **ECS Logging** is an open standard (NDJSON, `ecs.version`, canonical field names) — works with Elasticsearch, Datadog, GCP log agents, etc.
|
|
55
|
+
2. **stderr + JSONL** keeps stdout free for CLI output and matches twelve-factor log collection
|
|
56
|
+
3. **W3C Trace Context** (`traceparent`) enables cross-service correlation without vendor-specific field layouts
|
|
57
|
+
4. **`program.log.enrich`** — additive hook for consumer-specific fields; cannot override the ECS baseline
|
|
58
|
+
5. **`program.log.serialize`** — escape hatch for full custom lines in consumer repos (argsbarg does not endorse that output as ECS)
|
|
59
|
+
6. **No Tyson / OTel SDK in core** — proprietary or heavy observability stacks belong in consumer config or infra (Fluent Bit remapping), not in the open-source framework
|
package/docs/http-server.md
CHANGED
|
@@ -49,7 +49,9 @@ Set `httpServer` on the **program root only**. Validation rejects `httpServer` o
|
|
|
49
49
|
|
|
50
50
|
`httpServer` and `mcpServer` are independent — enable either or both.
|
|
51
51
|
|
|
52
|
-
|
|
52
|
+
## Logging
|
|
53
|
+
|
|
54
|
+
Server logs (access lines, errors, startup) go to **stderr** as JSON by default. See **[logging.md](logging.md)** for `program.log`, **`enrich`**, **`serialize`**, trace headers, and examples.
|
|
53
55
|
|
|
54
56
|
## REST routes
|
|
55
57
|
|
package/docs/logging.md
ADDED
|
@@ -0,0 +1,149 @@
|
|
|
1
|
+
# Server logging
|
|
2
|
+
|
|
3
|
+
When you run `myapp http` or `myapp mcp`, Argsbarg writes **server logs to stderr** — not to stdout (handlers and CLI output stay on stdout).
|
|
4
|
+
|
|
5
|
+
By default each log line is **one JSON object** (NDJSON), shaped for the [ECS Logging](https://github.com/elastic/ecs-logging) convention. That plays nicely with Datadog, Elasticsearch, GCP Logging, and similar collectors.
|
|
6
|
+
|
|
7
|
+
For local development, switch to plain text with `--log-format text` or `program.log.format: "text"`.
|
|
8
|
+
|
|
9
|
+
## What gets logged
|
|
10
|
+
|
|
11
|
+
| Event | When | `event.action` |
|
|
12
|
+
| --- | --- | --- |
|
|
13
|
+
| Server start | HTTP/MCP process listens | `http.server.start` / `server.start` |
|
|
14
|
+
| Access | After each HTTP request or MCP JSON-RPC message | `http.access` / `mcp.access` |
|
|
15
|
+
| Invoke error | After `formatError` → `onError`, before the client sees the error | `invoke.error` |
|
|
16
|
+
|
|
17
|
+
Toggle access or error lines with `program.log.access` and `program.log.errors` (both default to `true`).
|
|
18
|
+
|
|
19
|
+
## Example line (default JSON)
|
|
20
|
+
|
|
21
|
+
After `GET /workspaces` returns 200 in 45ms:
|
|
22
|
+
|
|
23
|
+
```json
|
|
24
|
+
{
|
|
25
|
+
"@timestamp": "2026-07-27T14:00:00.000Z",
|
|
26
|
+
"log.level": "info",
|
|
27
|
+
"message": "GET /workspaces",
|
|
28
|
+
"ecs.version": "8.11.0",
|
|
29
|
+
"service.name": "myapp",
|
|
30
|
+
"service.version": "1.0.0",
|
|
31
|
+
"event.action": "http.access",
|
|
32
|
+
"http.request.method": "GET",
|
|
33
|
+
"url.path": "/workspaces",
|
|
34
|
+
"http.response.status_code": 200,
|
|
35
|
+
"event.duration": 45000000,
|
|
36
|
+
"labels": { "request_id": "…" }
|
|
37
|
+
}
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
`event.duration` is in **nanoseconds** (ECS convention). Durations in hook callbacks (`durationMs`) stay in milliseconds.
|
|
41
|
+
|
|
42
|
+
When the client sends a W3C **`traceparent`** header, lines also include `trace.id` and `span.id`, and the response echoes an updated `traceparent`.
|
|
43
|
+
|
|
44
|
+
## `program.log` options
|
|
45
|
+
|
|
46
|
+
Set on the **program root** (same level as `httpServer` / `mcpServer`):
|
|
47
|
+
|
|
48
|
+
```typescript
|
|
49
|
+
const program = {
|
|
50
|
+
key: "myapp",
|
|
51
|
+
version: "1.0.0",
|
|
52
|
+
description: "…",
|
|
53
|
+
log: {
|
|
54
|
+
format: "json", // "text" for human-readable stderr
|
|
55
|
+
file: "server.log", // optional tee; relative paths → app config dir
|
|
56
|
+
access: true, // HTTP/MCP access lines
|
|
57
|
+
errors: true, // invoke error lines
|
|
58
|
+
},
|
|
59
|
+
// …
|
|
60
|
+
} satisfies CliProgram;
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
| Field | Default | Purpose |
|
|
64
|
+
| --- | --- | --- |
|
|
65
|
+
| `format` | `"json"` | `"json"` = ECS Logging NDJSON; `"text"` = `INFO [http.access]: GET /path` |
|
|
66
|
+
| `file` | — | Append the same lines to this path |
|
|
67
|
+
| `access` | `true` | Emit one line per HTTP request / MCP message |
|
|
68
|
+
| `errors` | `true` | Emit when a user command fails on HTTP/MCP |
|
|
69
|
+
| `enrich` | — | Add custom fields to each JSON line (see below) |
|
|
70
|
+
| `serialize` | — | Replace the built-in formatter entirely (see below) |
|
|
71
|
+
|
|
72
|
+
CLI overrides on `myapp http` and `myapp mcp serve`: `--log-format`, `--log-file`, `--no-access-log` (HTTP only), `--dev` (print full stacks to stderr on errors).
|
|
73
|
+
|
|
74
|
+
## `program.log.enrich` — add fields
|
|
75
|
+
|
|
76
|
+
Use **`enrich`** when you want **extra JSON fields** on top of the default ECS line — for example a team label, deployment cell, or a shape your log pipeline expects.
|
|
77
|
+
|
|
78
|
+
`enrich` is **additive only**. It cannot change `@timestamp`, `log.level`, `message`, `ecs.version`, `service.name`, `service.version`, or any field Argsbarg already set on that line.
|
|
79
|
+
|
|
80
|
+
```typescript
|
|
81
|
+
import type { LogEnrichContext } from "argsbarg";
|
|
82
|
+
|
|
83
|
+
const program = {
|
|
84
|
+
// …
|
|
85
|
+
log: {
|
|
86
|
+
format: "json",
|
|
87
|
+
enrich: (ctx: LogEnrichContext) => {
|
|
88
|
+
// Always available:
|
|
89
|
+
// ctx.level, ctx.message, ctx.action, ctx.service.name, ctx.service.version
|
|
90
|
+
// ctx.requestId, ctx.traceId, ctx.spanId (when present)
|
|
91
|
+
// ctx.labels, ctx.error (on error lines)
|
|
92
|
+
|
|
93
|
+
// On access logs (http.access / mcp.access):
|
|
94
|
+
// ctx.http.method, ctx.http.path, ctx.http.status, ctx.http.durationMs, ctx.http.clientIp
|
|
95
|
+
|
|
96
|
+
return {
|
|
97
|
+
deployment: "prod",
|
|
98
|
+
};
|
|
99
|
+
},
|
|
100
|
+
},
|
|
101
|
+
} satisfies CliProgram;
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
Return a flat object of field names → values. Argsbarg merges each key onto the log line unless that key is already set. To add team metadata inside ECS `labels`, put it in `event.labels` via hooks rather than fighting merge order — or use `serialize` for full control.
|
|
105
|
+
|
|
106
|
+
## `program.log.serialize` — own the whole line
|
|
107
|
+
|
|
108
|
+
Use **`serialize`** when the default ECS line is not what you need — for example a legacy JSON schema used only in your organization.
|
|
109
|
+
|
|
110
|
+
When `serialize` is set, Argsbarg **does not** run the ECS formatter. Your function receives the same `LogEnrichContext` as `enrich` and must return the **full line text without a trailing newline** (Argsbarg adds `\n`).
|
|
111
|
+
|
|
112
|
+
```typescript
|
|
113
|
+
import type { LogEnrichContext } from "argsbarg";
|
|
114
|
+
|
|
115
|
+
const program = {
|
|
116
|
+
// …
|
|
117
|
+
log: {
|
|
118
|
+
format: "json",
|
|
119
|
+
serialize: (ctx: LogEnrichContext) =>
|
|
120
|
+
JSON.stringify({
|
|
121
|
+
message: ctx.message,
|
|
122
|
+
level: ctx.level.toUpperCase(),
|
|
123
|
+
contextMap: {
|
|
124
|
+
...(ctx.traceId ? { trace_id: ctx.traceId } : {}),
|
|
125
|
+
...(ctx.spanId ? { span_id: ctx.spanId } : {}),
|
|
126
|
+
},
|
|
127
|
+
}),
|
|
128
|
+
},
|
|
129
|
+
} satisfies CliProgram;
|
|
130
|
+
```
|
|
131
|
+
|
|
132
|
+
Do **not** set both `enrich` and `serialize` expecting both to apply — `serialize` wins and `enrich` is ignored.
|
|
133
|
+
|
|
134
|
+
Prefer **`enrich`** when you only need a few extra fields. Reserve **`serialize`** for fully custom output.
|
|
135
|
+
|
|
136
|
+
## Trace correlation (HTTP)
|
|
137
|
+
|
|
138
|
+
If an upstream service (gateway, sidecar, mesh) sends a standard **`traceparent`** header:
|
|
139
|
+
|
|
140
|
+
1. Argsbarg parses it and logs `trace.id` / `span.id`.
|
|
141
|
+
2. The HTTP response includes an updated `traceparent` for this hop.
|
|
142
|
+
|
|
143
|
+
No configuration required. If the header is missing, Argsbarg does not invent a trace id.
|
|
144
|
+
|
|
145
|
+
## Related
|
|
146
|
+
|
|
147
|
+
- [http-server.md](http-server.md) — HTTP server setup and endpoints
|
|
148
|
+
- [mcp.md](mcp.md) — MCP server (same `program.log` applies)
|
|
149
|
+
- [decisions.md](decisions.md#structured-logging-ecs-logging) — why ECS Logging and hooks instead of a bundled observability SDK
|
|
@@ -161,7 +161,7 @@
|
|
|
161
161
|
},
|
|
162
162
|
{
|
|
163
163
|
"name": "log-format",
|
|
164
|
-
"description": "Log format: json (ECS) or text.",
|
|
164
|
+
"description": "Log format: json (ECS Logging) or text.",
|
|
165
165
|
"kind": "enum",
|
|
166
166
|
"choices": [
|
|
167
167
|
"json",
|
|
@@ -215,7 +215,7 @@
|
|
|
215
215
|
},
|
|
216
216
|
{
|
|
217
217
|
"name": "log-format",
|
|
218
|
-
"description": "Log format: json (ECS) or text.",
|
|
218
|
+
"description": "Log format: json (ECS Logging) or text.",
|
|
219
219
|
"kind": "enum",
|
|
220
220
|
"choices": [
|
|
221
221
|
"json",
|
|
@@ -394,7 +394,7 @@
|
|
|
394
394
|
},
|
|
395
395
|
{
|
|
396
396
|
"name": "log-format",
|
|
397
|
-
"description": "Log format: json (ECS) or text.",
|
|
397
|
+
"description": "Log format: json (ECS Logging) or text.",
|
|
398
398
|
"kind": "enum",
|
|
399
399
|
"choices": [
|
|
400
400
|
"json",
|
|
@@ -448,7 +448,7 @@
|
|
|
448
448
|
},
|
|
449
449
|
{
|
|
450
450
|
"name": "log-format",
|
|
451
|
-
"description": "Log format: json (ECS) or text.",
|
|
451
|
+
"description": "Log format: json (ECS Logging) or text.",
|
|
452
452
|
"kind": "enum",
|
|
453
453
|
"choices": [
|
|
454
454
|
"json",
|
|
@@ -649,7 +649,7 @@
|
|
|
649
649
|
},
|
|
650
650
|
{
|
|
651
651
|
"name": "log-format",
|
|
652
|
-
"description": "Log format: json (ECS) or text.",
|
|
652
|
+
"description": "Log format: json (ECS Logging) or text.",
|
|
653
653
|
"kind": "enum",
|
|
654
654
|
"choices": [
|
|
655
655
|
"json",
|
|
@@ -703,7 +703,7 @@
|
|
|
703
703
|
},
|
|
704
704
|
{
|
|
705
705
|
"name": "log-format",
|
|
706
|
-
"description": "Log format: json (ECS) or text.",
|
|
706
|
+
"description": "Log format: json (ECS Logging) or text.",
|
|
707
707
|
"kind": "enum",
|
|
708
708
|
"choices": [
|
|
709
709
|
"json",
|
|
@@ -886,7 +886,7 @@
|
|
|
886
886
|
},
|
|
887
887
|
{
|
|
888
888
|
"name": "log-format",
|
|
889
|
-
"description": "Log format: json (ECS) or text.",
|
|
889
|
+
"description": "Log format: json (ECS Logging) or text.",
|
|
890
890
|
"kind": "enum",
|
|
891
891
|
"choices": [
|
|
892
892
|
"json",
|
|
@@ -940,7 +940,7 @@
|
|
|
940
940
|
},
|
|
941
941
|
{
|
|
942
942
|
"name": "log-format",
|
|
943
|
-
"description": "Log format: json (ECS) or text.",
|
|
943
|
+
"description": "Log format: json (ECS Logging) or text.",
|
|
944
944
|
"kind": "enum",
|
|
945
945
|
"choices": [
|
|
946
946
|
"json",
|
|
@@ -1119,7 +1119,7 @@
|
|
|
1119
1119
|
},
|
|
1120
1120
|
{
|
|
1121
1121
|
"name": "log-format",
|
|
1122
|
-
"description": "Log format: json (ECS) or text.",
|
|
1122
|
+
"description": "Log format: json (ECS Logging) or text.",
|
|
1123
1123
|
"kind": "enum",
|
|
1124
1124
|
"choices": [
|
|
1125
1125
|
"json",
|
|
@@ -1173,7 +1173,7 @@
|
|
|
1173
1173
|
},
|
|
1174
1174
|
{
|
|
1175
1175
|
"name": "log-format",
|
|
1176
|
-
"description": "Log format: json (ECS) or text.",
|
|
1176
|
+
"description": "Log format: json (ECS Logging) or text.",
|
|
1177
1177
|
"kind": "enum",
|
|
1178
1178
|
"choices": [
|
|
1179
1179
|
"json",
|
|
@@ -1356,7 +1356,7 @@
|
|
|
1356
1356
|
},
|
|
1357
1357
|
{
|
|
1358
1358
|
"name": "log-format",
|
|
1359
|
-
"description": "Log format: json (ECS) or text.",
|
|
1359
|
+
"description": "Log format: json (ECS Logging) or text.",
|
|
1360
1360
|
"kind": "enum",
|
|
1361
1361
|
"choices": [
|
|
1362
1362
|
"json",
|
|
@@ -1410,7 +1410,7 @@
|
|
|
1410
1410
|
},
|
|
1411
1411
|
{
|
|
1412
1412
|
"name": "log-format",
|
|
1413
|
-
"description": "Log format: json (ECS) or text.",
|
|
1413
|
+
"description": "Log format: json (ECS Logging) or text.",
|
|
1414
1414
|
"kind": "enum",
|
|
1415
1415
|
"choices": [
|
|
1416
1416
|
"json",
|
|
@@ -1589,7 +1589,7 @@
|
|
|
1589
1589
|
},
|
|
1590
1590
|
{
|
|
1591
1591
|
"name": "log-format",
|
|
1592
|
-
"description": "Log format: json (ECS) or text.",
|
|
1592
|
+
"description": "Log format: json (ECS Logging) or text.",
|
|
1593
1593
|
"kind": "enum",
|
|
1594
1594
|
"choices": [
|
|
1595
1595
|
"json",
|
|
@@ -1643,7 +1643,7 @@
|
|
|
1643
1643
|
},
|
|
1644
1644
|
{
|
|
1645
1645
|
"name": "log-format",
|
|
1646
|
-
"description": "Log format: json (ECS) or text.",
|
|
1646
|
+
"description": "Log format: json (ECS Logging) or text.",
|
|
1647
1647
|
"kind": "enum",
|
|
1648
1648
|
"choices": [
|
|
1649
1649
|
"json",
|
|
@@ -1822,7 +1822,7 @@
|
|
|
1822
1822
|
},
|
|
1823
1823
|
{
|
|
1824
1824
|
"name": "log-format",
|
|
1825
|
-
"description": "Log format: json (ECS) or text.",
|
|
1825
|
+
"description": "Log format: json (ECS Logging) or text.",
|
|
1826
1826
|
"kind": "enum",
|
|
1827
1827
|
"choices": [
|
|
1828
1828
|
"json",
|
|
@@ -1876,7 +1876,7 @@
|
|
|
1876
1876
|
},
|
|
1877
1877
|
{
|
|
1878
1878
|
"name": "log-format",
|
|
1879
|
-
"description": "Log format: json (ECS) or text.",
|
|
1879
|
+
"description": "Log format: json (ECS Logging) or text.",
|
|
1880
1880
|
"kind": "enum",
|
|
1881
1881
|
"choices": [
|
|
1882
1882
|
"json",
|
|
@@ -2055,7 +2055,7 @@
|
|
|
2055
2055
|
},
|
|
2056
2056
|
{
|
|
2057
2057
|
"name": "log-format",
|
|
2058
|
-
"description": "Log format: json (ECS) or text.",
|
|
2058
|
+
"description": "Log format: json (ECS Logging) or text.",
|
|
2059
2059
|
"kind": "enum",
|
|
2060
2060
|
"choices": [
|
|
2061
2061
|
"json",
|
|
@@ -2109,7 +2109,7 @@
|
|
|
2109
2109
|
},
|
|
2110
2110
|
{
|
|
2111
2111
|
"name": "log-format",
|
|
2112
|
-
"description": "Log format: json (ECS) or text.",
|
|
2112
|
+
"description": "Log format: json (ECS Logging) or text.",
|
|
2113
2113
|
"kind": "enum",
|
|
2114
2114
|
"choices": [
|
|
2115
2115
|
"json",
|
|
@@ -195,7 +195,7 @@ MCP server and bundle tools.
|
|
|
195
195
|
| Option | Type | Required | Format / default | Description |
|
|
196
196
|
| --- | --- | --- | --- | --- |
|
|
197
197
|
| `--obscure-errors` | flag | optional | — | Hide unexpected errors from clients. |
|
|
198
|
-
| `--log-format` | enum (`json`, `text`) | optional | — | Log format: json (ECS) or text. |
|
|
198
|
+
| `--log-format` | enum (`json`, `text`) | optional | — | Log format: json (ECS Logging) or text. |
|
|
199
199
|
| `--log-file` | string | optional | — | Append logs to this file (relative → app config dir). |
|
|
200
200
|
| `--dev` | flag | optional | — | Print full stacks to stderr on errors. |
|
|
201
201
|
|
|
@@ -231,7 +231,7 @@ HTTP API server for tools.
|
|
|
231
231
|
| `--port` | number | optional | — | Listen port. |
|
|
232
232
|
| `--trust-proxy` | flag | optional | — | Honor X-Forwarded-For for client IP. |
|
|
233
233
|
| `--obscure-errors` | flag | optional | — | Hide unexpected errors from clients. |
|
|
234
|
-
| `--log-format` | enum (`json`, `text`) | optional | — | Log format: json (ECS) or text. |
|
|
234
|
+
| `--log-format` | enum (`json`, `text`) | optional | — | Log format: json (ECS Logging) or text. |
|
|
235
235
|
| `--log-file` | string | optional | — | Append logs to this file (relative → app config dir). |
|
|
236
236
|
| `--no-access-log` | flag | optional | — | Disable HTTP access logs. |
|
|
237
237
|
| `--dev` | flag | optional | — | Print full stacks to stderr on errors. |
|
|
@@ -408,7 +408,7 @@ MCP server and bundle tools.
|
|
|
408
408
|
| Option | Type | Required | Format / default | Description |
|
|
409
409
|
| --- | --- | --- | --- | --- |
|
|
410
410
|
| `--obscure-errors` | flag | optional | — | Hide unexpected errors from clients. |
|
|
411
|
-
| `--log-format` | enum (`json`, `text`) | optional | — | Log format: json (ECS) or text. |
|
|
411
|
+
| `--log-format` | enum (`json`, `text`) | optional | — | Log format: json (ECS Logging) or text. |
|
|
412
412
|
| `--log-file` | string | optional | — | Append logs to this file (relative → app config dir). |
|
|
413
413
|
| `--dev` | flag | optional | — | Print full stacks to stderr on errors. |
|
|
414
414
|
|
|
@@ -444,7 +444,7 @@ HTTP API server for tools.
|
|
|
444
444
|
| `--port` | number | optional | — | Listen port. |
|
|
445
445
|
| `--trust-proxy` | flag | optional | — | Honor X-Forwarded-For for client IP. |
|
|
446
446
|
| `--obscure-errors` | flag | optional | — | Hide unexpected errors from clients. |
|
|
447
|
-
| `--log-format` | enum (`json`, `text`) | optional | — | Log format: json (ECS) or text. |
|
|
447
|
+
| `--log-format` | enum (`json`, `text`) | optional | — | Log format: json (ECS Logging) or text. |
|
|
448
448
|
| `--log-file` | string | optional | — | Append logs to this file (relative → app config dir). |
|
|
449
449
|
| `--no-access-log` | flag | optional | — | Disable HTTP access logs. |
|
|
450
450
|
| `--dev` | flag | optional | — | Print full stacks to stderr on errors. |
|
|
@@ -649,7 +649,7 @@ MCP server and bundle tools.
|
|
|
649
649
|
| Option | Type | Required | Format / default | Description |
|
|
650
650
|
| --- | --- | --- | --- | --- |
|
|
651
651
|
| `--obscure-errors` | flag | optional | — | Hide unexpected errors from clients. |
|
|
652
|
-
| `--log-format` | enum (`json`, `text`) | optional | — | Log format: json (ECS) or text. |
|
|
652
|
+
| `--log-format` | enum (`json`, `text`) | optional | — | Log format: json (ECS Logging) or text. |
|
|
653
653
|
| `--log-file` | string | optional | — | Append logs to this file (relative → app config dir). |
|
|
654
654
|
| `--dev` | flag | optional | — | Print full stacks to stderr on errors. |
|
|
655
655
|
|
|
@@ -685,7 +685,7 @@ HTTP API server for tools.
|
|
|
685
685
|
| `--port` | number | optional | — | Listen port. |
|
|
686
686
|
| `--trust-proxy` | flag | optional | — | Honor X-Forwarded-For for client IP. |
|
|
687
687
|
| `--obscure-errors` | flag | optional | — | Hide unexpected errors from clients. |
|
|
688
|
-
| `--log-format` | enum (`json`, `text`) | optional | — | Log format: json (ECS) or text. |
|
|
688
|
+
| `--log-format` | enum (`json`, `text`) | optional | — | Log format: json (ECS Logging) or text. |
|
|
689
689
|
| `--log-file` | string | optional | — | Append logs to this file (relative → app config dir). |
|
|
690
690
|
| `--no-access-log` | flag | optional | — | Disable HTTP access logs. |
|
|
691
691
|
| `--dev` | flag | optional | — | Print full stacks to stderr on errors. |
|
|
@@ -872,7 +872,7 @@ MCP server and bundle tools.
|
|
|
872
872
|
| Option | Type | Required | Format / default | Description |
|
|
873
873
|
| --- | --- | --- | --- | --- |
|
|
874
874
|
| `--obscure-errors` | flag | optional | — | Hide unexpected errors from clients. |
|
|
875
|
-
| `--log-format` | enum (`json`, `text`) | optional | — | Log format: json (ECS) or text. |
|
|
875
|
+
| `--log-format` | enum (`json`, `text`) | optional | — | Log format: json (ECS Logging) or text. |
|
|
876
876
|
| `--log-file` | string | optional | — | Append logs to this file (relative → app config dir). |
|
|
877
877
|
| `--dev` | flag | optional | — | Print full stacks to stderr on errors. |
|
|
878
878
|
|
|
@@ -908,7 +908,7 @@ HTTP API server for tools.
|
|
|
908
908
|
| `--port` | number | optional | — | Listen port. |
|
|
909
909
|
| `--trust-proxy` | flag | optional | — | Honor X-Forwarded-For for client IP. |
|
|
910
910
|
| `--obscure-errors` | flag | optional | — | Hide unexpected errors from clients. |
|
|
911
|
-
| `--log-format` | enum (`json`, `text`) | optional | — | Log format: json (ECS) or text. |
|
|
911
|
+
| `--log-format` | enum (`json`, `text`) | optional | — | Log format: json (ECS Logging) or text. |
|
|
912
912
|
| `--log-file` | string | optional | — | Append logs to this file (relative → app config dir). |
|
|
913
913
|
| `--no-access-log` | flag | optional | — | Disable HTTP access logs. |
|
|
914
914
|
| `--dev` | flag | optional | — | Print full stacks to stderr on errors. |
|
|
@@ -1085,7 +1085,7 @@ MCP server and bundle tools.
|
|
|
1085
1085
|
| Option | Type | Required | Format / default | Description |
|
|
1086
1086
|
| --- | --- | --- | --- | --- |
|
|
1087
1087
|
| `--obscure-errors` | flag | optional | — | Hide unexpected errors from clients. |
|
|
1088
|
-
| `--log-format` | enum (`json`, `text`) | optional | — | Log format: json (ECS) or text. |
|
|
1088
|
+
| `--log-format` | enum (`json`, `text`) | optional | — | Log format: json (ECS Logging) or text. |
|
|
1089
1089
|
| `--log-file` | string | optional | — | Append logs to this file (relative → app config dir). |
|
|
1090
1090
|
| `--dev` | flag | optional | — | Print full stacks to stderr on errors. |
|
|
1091
1091
|
|
|
@@ -1121,7 +1121,7 @@ HTTP API server for tools.
|
|
|
1121
1121
|
| `--port` | number | optional | — | Listen port. |
|
|
1122
1122
|
| `--trust-proxy` | flag | optional | — | Honor X-Forwarded-For for client IP. |
|
|
1123
1123
|
| `--obscure-errors` | flag | optional | — | Hide unexpected errors from clients. |
|
|
1124
|
-
| `--log-format` | enum (`json`, `text`) | optional | — | Log format: json (ECS) or text. |
|
|
1124
|
+
| `--log-format` | enum (`json`, `text`) | optional | — | Log format: json (ECS Logging) or text. |
|
|
1125
1125
|
| `--log-file` | string | optional | — | Append logs to this file (relative → app config dir). |
|
|
1126
1126
|
| `--no-access-log` | flag | optional | — | Disable HTTP access logs. |
|
|
1127
1127
|
| `--dev` | flag | optional | — | Print full stacks to stderr on errors. |
|
|
@@ -1309,7 +1309,7 @@ MCP server and bundle tools.
|
|
|
1309
1309
|
| Option | Type | Required | Format / default | Description |
|
|
1310
1310
|
| --- | --- | --- | --- | --- |
|
|
1311
1311
|
| `--obscure-errors` | flag | optional | — | Hide unexpected errors from clients. |
|
|
1312
|
-
| `--log-format` | enum (`json`, `text`) | optional | — | Log format: json (ECS) or text. |
|
|
1312
|
+
| `--log-format` | enum (`json`, `text`) | optional | — | Log format: json (ECS Logging) or text. |
|
|
1313
1313
|
| `--log-file` | string | optional | — | Append logs to this file (relative → app config dir). |
|
|
1314
1314
|
| `--dev` | flag | optional | — | Print full stacks to stderr on errors. |
|
|
1315
1315
|
|
|
@@ -1345,7 +1345,7 @@ HTTP API server for tools.
|
|
|
1345
1345
|
| `--port` | number | optional | — | Listen port. |
|
|
1346
1346
|
| `--trust-proxy` | flag | optional | — | Honor X-Forwarded-For for client IP. |
|
|
1347
1347
|
| `--obscure-errors` | flag | optional | — | Hide unexpected errors from clients. |
|
|
1348
|
-
| `--log-format` | enum (`json`, `text`) | optional | — | Log format: json (ECS) or text. |
|
|
1348
|
+
| `--log-format` | enum (`json`, `text`) | optional | — | Log format: json (ECS Logging) or text. |
|
|
1349
1349
|
| `--log-file` | string | optional | — | Append logs to this file (relative → app config dir). |
|
|
1350
1350
|
| `--no-access-log` | flag | optional | — | Disable HTTP access logs. |
|
|
1351
1351
|
| `--dev` | flag | optional | — | Print full stacks to stderr on errors. |
|
|
@@ -1522,7 +1522,7 @@ MCP server and bundle tools.
|
|
|
1522
1522
|
| Option | Type | Required | Format / default | Description |
|
|
1523
1523
|
| --- | --- | --- | --- | --- |
|
|
1524
1524
|
| `--obscure-errors` | flag | optional | — | Hide unexpected errors from clients. |
|
|
1525
|
-
| `--log-format` | enum (`json`, `text`) | optional | — | Log format: json (ECS) or text. |
|
|
1525
|
+
| `--log-format` | enum (`json`, `text`) | optional | — | Log format: json (ECS Logging) or text. |
|
|
1526
1526
|
| `--log-file` | string | optional | — | Append logs to this file (relative → app config dir). |
|
|
1527
1527
|
| `--dev` | flag | optional | — | Print full stacks to stderr on errors. |
|
|
1528
1528
|
|
|
@@ -1558,7 +1558,7 @@ HTTP API server for tools.
|
|
|
1558
1558
|
| `--port` | number | optional | — | Listen port. |
|
|
1559
1559
|
| `--trust-proxy` | flag | optional | — | Honor X-Forwarded-For for client IP. |
|
|
1560
1560
|
| `--obscure-errors` | flag | optional | — | Hide unexpected errors from clients. |
|
|
1561
|
-
| `--log-format` | enum (`json`, `text`) | optional | — | Log format: json (ECS) or text. |
|
|
1561
|
+
| `--log-format` | enum (`json`, `text`) | optional | — | Log format: json (ECS Logging) or text. |
|
|
1562
1562
|
| `--log-file` | string | optional | — | Append logs to this file (relative → app config dir). |
|
|
1563
1563
|
| `--no-access-log` | flag | optional | — | Disable HTTP access logs. |
|
|
1564
1564
|
| `--dev` | flag | optional | — | Print full stacks to stderr on errors. |
|
|
@@ -1735,7 +1735,7 @@ MCP server and bundle tools.
|
|
|
1735
1735
|
| Option | Type | Required | Format / default | Description |
|
|
1736
1736
|
| --- | --- | --- | --- | --- |
|
|
1737
1737
|
| `--obscure-errors` | flag | optional | — | Hide unexpected errors from clients. |
|
|
1738
|
-
| `--log-format` | enum (`json`, `text`) | optional | — | Log format: json (ECS) or text. |
|
|
1738
|
+
| `--log-format` | enum (`json`, `text`) | optional | — | Log format: json (ECS Logging) or text. |
|
|
1739
1739
|
| `--log-file` | string | optional | — | Append logs to this file (relative → app config dir). |
|
|
1740
1740
|
| `--dev` | flag | optional | — | Print full stacks to stderr on errors. |
|
|
1741
1741
|
|
|
@@ -1771,7 +1771,7 @@ HTTP API server for tools.
|
|
|
1771
1771
|
| `--port` | number | optional | — | Listen port. |
|
|
1772
1772
|
| `--trust-proxy` | flag | optional | — | Honor X-Forwarded-For for client IP. |
|
|
1773
1773
|
| `--obscure-errors` | flag | optional | — | Hide unexpected errors from clients. |
|
|
1774
|
-
| `--log-format` | enum (`json`, `text`) | optional | — | Log format: json (ECS) or text. |
|
|
1774
|
+
| `--log-format` | enum (`json`, `text`) | optional | — | Log format: json (ECS Logging) or text. |
|
|
1775
1775
|
| `--log-file` | string | optional | — | Append logs to this file (relative → app config dir). |
|
|
1776
1776
|
| `--no-access-log` | flag | optional | — | Disable HTTP access logs. |
|
|
1777
1777
|
| `--dev` | flag | optional | — | Print full stacks to stderr on errors. |
|
|
@@ -1948,7 +1948,7 @@ MCP server and bundle tools.
|
|
|
1948
1948
|
| Option | Type | Required | Format / default | Description |
|
|
1949
1949
|
| --- | --- | --- | --- | --- |
|
|
1950
1950
|
| `--obscure-errors` | flag | optional | — | Hide unexpected errors from clients. |
|
|
1951
|
-
| `--log-format` | enum (`json`, `text`) | optional | — | Log format: json (ECS) or text. |
|
|
1951
|
+
| `--log-format` | enum (`json`, `text`) | optional | — | Log format: json (ECS Logging) or text. |
|
|
1952
1952
|
| `--log-file` | string | optional | — | Append logs to this file (relative → app config dir). |
|
|
1953
1953
|
| `--dev` | flag | optional | — | Print full stacks to stderr on errors. |
|
|
1954
1954
|
|
|
@@ -1984,7 +1984,7 @@ HTTP API server for tools.
|
|
|
1984
1984
|
| `--port` | number | optional | — | Listen port. |
|
|
1985
1985
|
| `--trust-proxy` | flag | optional | — | Honor X-Forwarded-For for client IP. |
|
|
1986
1986
|
| `--obscure-errors` | flag | optional | — | Hide unexpected errors from clients. |
|
|
1987
|
-
| `--log-format` | enum (`json`, `text`) | optional | — | Log format: json (ECS) or text. |
|
|
1987
|
+
| `--log-format` | enum (`json`, `text`) | optional | — | Log format: json (ECS Logging) or text. |
|
|
1988
1988
|
| `--log-file` | string | optional | — | Append logs to this file (relative → app config dir). |
|
|
1989
1989
|
| `--no-access-log` | flag | optional | — | Disable HTTP access logs. |
|
|
1990
1990
|
| `--dev` | flag | optional | — | Print full stacks to stderr on errors. |
|
|
@@ -45,6 +45,16 @@ Handlers must use `ctx.respond()` or return a value for API/MCP tool calls.
|
|
|
45
45
|
|
|
46
46
|
Errors use `{ "error": "..." }` with `400`, `404`, `503`, or `500`.
|
|
47
47
|
|
|
48
|
+
## Logging
|
|
49
|
+
|
|
50
|
+
Server logs go to **stderr** (one JSON object per line by default).
|
|
51
|
+
|
|
52
|
+
- Configure with `program.log` on the program root
|
|
53
|
+
- **`enrich`** — add custom JSON fields on top of the default line
|
|
54
|
+
- **`serialize`** — replace the formatter and emit your own line shape
|
|
55
|
+
|
|
56
|
+
See the argsbarg [logging guide](https://github.com/bdombro/bun-argsbarg/blob/main/docs/logging.md) for examples and the full `LogEnrichContext` shape.
|
|
57
|
+
|
|
48
58
|
## REST routes
|
|
49
59
|
|
|
50
60
|
- `POST /echo` (CLI: `full-example echo`) — Echo a message (MCP-friendly leaf).
|