feat(egress): add global log option for full request/response logging
Adds a top-level `log: true` option to the egress config that logs the full request (method, path, headers, body) and response (status, headers, body) for every forwarded connection as JSON lines on stderr. Wire format: `log: true` at the root of routes.yaml, parsed into the new `Config` dataclass alongside `routes`. The sidecar addon switches from `self.routes` to `self.config` and writes `_log_request` / `_log_response` JSON lines when `self.config.log` is set. Manifest: `egress.log: true` in bottle YAML flows through `EgressConfig.Log` → `Egress.prepare()` → `egress_render_routes(..., log=)` → routes.yaml. `EgressPlan` also carries the flag for introspection. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -346,6 +346,25 @@ class TestConfigShape(unittest.TestCase):
|
||||
"bottle": "dev"}},
|
||||
})
|
||||
|
||||
def test_log_defaults_false(self):
|
||||
b = _bottle([])
|
||||
self.assertFalse(b.egress.Log)
|
||||
|
||||
def test_log_true_accepted(self):
|
||||
b = Manifest.from_json_obj({
|
||||
"bottles": {"dev": {"egress": {"log": True, "routes": []}}},
|
||||
"agents": {"demo": {"skills": [], "prompt": "", "bottle": "dev"}},
|
||||
}).bottles["dev"]
|
||||
self.assertTrue(b.egress.Log)
|
||||
|
||||
def test_log_non_bool_rejected(self):
|
||||
with self.assertRaises(ManifestError):
|
||||
Manifest.from_json_obj({
|
||||
"bottles": {"dev": {"egress": {"log": "yes"}}},
|
||||
"agents": {"demo": {"skills": [], "prompt": "",
|
||||
"bottle": "dev"}},
|
||||
})
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
|
||||
Reference in New Issue
Block a user