MCPcopy
hub / github.com/aws/aws-lambda-go / ExampleNewLogHandler

Function ExampleNewLogHandler

lambdacontext/example_logger_test.go:28–36  ·  view source on GitHub ↗

ExampleNewLogHandler demonstrates using NewLogHandler for more control.

()

Source from the content-addressed store, hash-verified

26
27// ExampleNewLogHandler demonstrates using NewLogHandler for more control.
28func ExampleNewLogHandler() {
29 // Set up the Lambda-aware slog handler
30 slog.SetDefault(slog.New(lambdacontext.NewLogHandler()))
31
32 lambda.Start(func(ctx context.Context) (string, error) {
33 slog.InfoContext(ctx, "processing request", "action", "example")
34 return "success", nil
35 })
36}
37
38// ExampleNewLogHandler_withOptions demonstrates NewLogHandler with additional fields.
39// Use WithFunctionARN() and WithTenantID() to include extra context.

Callers

nothing calls this directly

Calls 2

NewLogHandlerFunction · 0.92
StartFunction · 0.92

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…