Skip to content

Ministack: Free, open-source local AWS emulator - 60+ services, Terraform compatible, real databases. Free forever. MIT licensed.

Update log retrieval to filter by invoke time (#459)

Kristoffer Sjöberg398a850bf11a
diff --git a/ministack/services/lambda_svc.py b/ministack/services/lambda_svc.py
index cbdd731e..2fbcfba1 100644
--- a/ministack/services/lambda_svc.py
+++ b/ministack/services/lambda_svc.py
@@ -1896,6 +1896,7 @@ def _invoke_rie(container, event: dict, timeout: int) -> dict:
if not ports:
continue
rie_url = f"http://127.0.0.1:{ports[0]['HostPort']}/2015-03-31/functions/function/invocations"
+ invoke_time = time.time()
req = urllib.request.Request(
rie_url, data=json.dumps(event).encode(),
headers={"Content-Type": "application/json"},
@@ -1906,7 +1907,7 @@ def _invoke_rie(container, event: dict, timeout: int) -> dict:
parsed = json.loads(body)
except json.JSONDecodeError:
parsed = body
- logs = container.logs(stdout=True, stderr=True).decode("utf-8", errors="replace").strip()
+ logs = container.logs(stdout=True, stderr=True, since=invoke_time).decode("utf-8", errors="replace").strip()
# RIE sets 'Lambda-Runtime-Function-Error-Type' (or bare
# 'X-Amz-Function-Error') when the handler raised an unhandled
# exception. If it's set we surface the error flag + propagate the