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

Function ExampleNewLogHandler_withOptions

lambdacontext/example_logger_test.go:40–51  ·  view source on GitHub ↗

ExampleNewLogHandler_withOptions demonstrates NewLogHandler with additional fields. Use WithFunctionARN() and WithTenantID() to include extra context.

()

Source from the content-addressed store, hash-verified

38// ExampleNewLogHandler_withOptions demonstrates NewLogHandler with additional fields.
39// Use WithFunctionARN() and WithTenantID() to include extra context.
40func ExampleNewLogHandler_withOptions() {
41 // Set up handler with function ARN and tenant ID fields
42 slog.SetDefault(slog.New(lambdacontext.NewLogHandler(
43 lambdacontext.WithFunctionARN(),
44 lambdacontext.WithTenantID(),
45 )))
46
47 lambda.Start(func(ctx context.Context) (string, error) {
48 slog.InfoContext(ctx, "multi-tenant request", "tenant", "acme-corp")
49 return "success", nil
50 })
51}
52
53// ExampleWithFunctionARN demonstrates using WithFunctionARN to include the function ARN.
54func ExampleWithFunctionARN() {

Callers

nothing calls this directly

Calls 4

NewLogHandlerFunction · 0.92
WithFunctionARNFunction · 0.92
WithTenantIDFunction · 0.92
StartFunction · 0.92

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…