From ea0c84547f0c07f58ae7148db20de44d8fda9ab7 Mon Sep 17 00:00:00 2001 From: sneak Date: Fri, 14 Jun 2024 05:39:08 -0700 Subject: [PATCH] add example script --- cmd/example/main.go | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 cmd/example/main.go diff --git a/cmd/example/main.go b/cmd/example/main.go new file mode 100644 index 0000000..fc17316 --- /dev/null +++ b/cmd/example/main.go @@ -0,0 +1,26 @@ +package main + +import ( + "log/slog" + + _ "sneak.berlin/go/simplelog" +) + +func main() { + + // log structured data with slog as usual: + slog.Info( + "User login attempt", + slog.String("user", "JohnDoe"), + slog.Int("attempt", 3), + ) + slog.Warn( + "Configuration mismatch", + slog.String("expected", "config.json"), + slog.String("found", "config.dev.json"), + ) + slog.Error( + "Failed to save data", + slog.String("reason", "permission denied"), + ) +}