Skip to content

Commit 0b0ae78

Browse files
committed
update docs and examples to use child context logger
1 parent d796682 commit 0b0ae78

3 files changed

Lines changed: 6 additions & 6 deletions

File tree

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -354,8 +354,8 @@ The SDK provides a `DurableLogger` via `ctx.getLogger()` that automatically incl
354354
protected OrderResult handleRequest(Order order, DurableContext ctx) {
355355
ctx.getLogger().info("Processing order: {}", order.getId());
356356

357-
var result = ctx.step("validate", String.class, () -> {
358-
ctx.getLogger().debug("Validating order details");
357+
var result = ctx.step("validate", String.class, stepCtx -> {
358+
stepCtx.getLogger().debug("Validating order details");
359359
return validate(order);
360360
});
361361

examples/src/main/java/software/amazon/lambda/durable/examples/CallbackExample.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,13 +47,13 @@ public String handleRequest(ApprovalRequest input, DurableContext context) {
4747
var callback = context.createCallback("approval", String.class, config);
4848

4949
// Step 2.5: Log AWS CLI command to complete the callback
50-
context.step("log-callback-command", Void.class, () -> {
50+
context.step("log-callback-command", Void.class, ctx -> {
5151
var callbackId = callback.callbackId();
5252
// The result must be base64-encoded JSON
5353
var command = String.format(
5454
"aws lambda send-durable-execution-callback-success --callback-id %s --result $(echo -n '\"approved\"' | base64)",
5555
callbackId);
56-
context.getLogger().info("To complete this callback, run: {}", command);
56+
ctx.getLogger().info("To complete this callback, run: {}", command);
5757
return null;
5858
});
5959

examples/src/main/java/software/amazon/lambda/durable/examples/ChildContextExample.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ public String handleRequest(GreetingRequest input, DurableContext context) {
3131
// Child context 1: Order validation — step + wait + step
3232
var orderFuture = context.runInChildContextAsync("order-validation", String.class, child -> {
3333
var prepared = child.step("prepare-order", String.class, () -> "Order for " + name);
34-
context.getLogger().info("Order prepared, waiting for validation");
34+
child.getLogger().info("Order prepared, waiting for validation");
3535

3636
child.wait("validation-delay", Duration.ofSeconds(5));
3737

@@ -41,7 +41,7 @@ public String handleRequest(GreetingRequest input, DurableContext context) {
4141
// Child context 2: Inventory check — step + wait + step
4242
var inventoryFuture = context.runInChildContextAsync("inventory-check", String.class, child -> {
4343
var stock = child.step("check-stock", String.class, () -> "Stock available for " + name);
44-
context.getLogger().info("Stock checked, waiting for confirmation");
44+
child.getLogger().info("Stock checked, waiting for confirmation");
4545

4646
child.wait("confirmation-delay", Duration.ofSeconds(3));
4747

0 commit comments

Comments
 (0)