| 1 | package main |
| 2 | |
| 3 | import ( |
| 4 | "context" |
| 5 | "log/slog" |
| 6 | "os" |
| 7 | |
| 8 | "github.com/chainguard-dev/clog" |
| 9 | ) |
| 10 | |
| 11 | func init() { |
| 12 | slog.SetDefault(slog.New(clog.NewHandler(slog.NewTextHandler(os.Stdout, nil)))) |
| 13 | } |
| 14 | |
| 15 | func main() { |
| 16 | ctx := context.Background() |
| 17 | ctx = clog.WithValues(ctx, "foo", "bar") |
| 18 | |
| 19 | // Use slog package directly |
| 20 | slog.InfoContext(ctx, "hello world", slog.Bool("baz", true)) |
| 21 | |
| 22 | // glog / zap style (note: can't pass additional attributes) |
| 23 | clog.Errorf("hello %s", "world") |
| 24 | } |