From d35d862b9efa222a3a2973a44d0b87cf7779e543 Mon Sep 17 00:00:00 2001 From: Alex Wang Date: Fri, 14 Nov 2025 18:59:23 -0800 Subject: [PATCH] fix: update logging example - Set logging level to info so that we can actually print logs at info level - Add logging for warn and error --- examples/src/logger_example/logger_example.py | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/examples/src/logger_example/logger_example.py b/examples/src/logger_example/logger_example.py index 16937ef..733ed65 100644 --- a/examples/src/logger_example/logger_example.py +++ b/examples/src/logger_example/logger_example.py @@ -4,10 +4,16 @@ from aws_durable_execution_sdk_python.context import ( DurableContext, + StepContext, durable_with_child_context, + durable_step, ) from aws_durable_execution_sdk_python.execution import durable_execution +import logging + +logging.getLogger().setLevel(logging.INFO) + @durable_with_child_context def child_workflow(ctx: DurableContext) -> str: @@ -26,6 +32,16 @@ def child_workflow(ctx: DurableContext) -> str: return child_result +@durable_step +def my_step(step_context: StepContext, my_arg: int) -> str: + step_context.logger.info("Hello from my_step") + step_context.logger.warning("Warning from my_step", extra={"my_arg": my_arg}) + step_context.logger.error( + "Error from my_step", extra={"my_arg": my_arg, "type": "error"} + ) + return f"from my_step: {my_arg}" + + @durable_execution def handler(event: Any, context: DurableContext) -> str: """Handler demonstrating logger usage.""" @@ -38,6 +54,8 @@ def handler(event: Any, context: DurableContext) -> str: name="process_data", ) + context.step(my_step(123)) + context.logger.info("Step 1 completed", extra={"result": result1}) # Child contexts inherit the parent's logger and have their own step ID