-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.go
44 lines (35 loc) · 800 Bytes
/
main.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
package main
import (
"log/slog"
"net/http"
"os"
"runtime"
"github.com/aws/aws-lambda-go/events"
"github.com/aws/aws-lambda-go/lambda"
)
func main() {
if os.Getenv("AWS_LAMBDA_FUNCTION_NAME") != "" {
lambda.Start(LogSlogExample)
} else {
LogSlogExample()
}
}
func LogSlogExample() (events.APIGatewayProxyResponse, error) {
// logger := NewTextHandler()
// logger := NewJSONHandler()
logger := NewJSONHandlerWithOptions()
// Set a logger variable to be used by the slog package
slog.SetDefault(logger)
// Levels
PrintLevels()
// Grouping
PrintWithInlineFields()
PrintWithSlogGroup()
PrintWithSlogWith()
AddToDefaultLogStructure("GOOS", runtime.GOOS)
// Redact
PrintWithRedactedFields()
return events.APIGatewayProxyResponse{
StatusCode: http.StatusOK,
}, nil
}