File tree Expand file tree Collapse file tree 1 file changed +18
-0
lines changed
examples/src/logger_example Expand file tree Collapse file tree 1 file changed +18
-0
lines changed Original file line number Diff line number Diff line change 44
55from aws_durable_execution_sdk_python .context import (
66 DurableContext ,
7+ StepContext ,
78 durable_with_child_context ,
9+ durable_step ,
810)
911from aws_durable_execution_sdk_python .execution import durable_execution
1012
13+ import logging
14+
15+ logging .getLogger ().setLevel (logging .INFO )
16+
1117
1218@durable_with_child_context
1319def child_workflow (ctx : DurableContext ) -> str :
@@ -26,6 +32,16 @@ def child_workflow(ctx: DurableContext) -> str:
2632 return child_result
2733
2834
35+ @durable_step
36+ def my_step (step_context : StepContext , my_arg : int ) -> str :
37+ step_context .logger .info ("Hello from my_step" )
38+ step_context .logger .warning ("Warning from my_step" , extra = {"my_arg" : my_arg })
39+ step_context .logger .error (
40+ "Error from my_step" , extra = {"my_arg" : my_arg , "type" : "error" }
41+ )
42+ return f"from my_step: { my_arg } "
43+
44+
2945@durable_execution
3046def handler (event : Any , context : DurableContext ) -> str :
3147 """Handler demonstrating logger usage."""
@@ -38,6 +54,8 @@ def handler(event: Any, context: DurableContext) -> str:
3854 name = "process_data" ,
3955 )
4056
57+ context .step (my_step (123 ))
58+
4159 context .logger .info ("Step 1 completed" , extra = {"result" : result1 })
4260
4361 # Child contexts inherit the parent's logger and have their own step ID
You can’t perform that action at this time.
0 commit comments