This website requires JavaScript.
Explore
Help
Sign in
imjasonh
/
clog
Watch
1
Star
0
Fork
You've already forked clog
0
mirror of
https://github.com/chainguard-dev/clog
synced
2026-07-06 22:12:46 +00:00
Code
Activity
main
clog
/
go.mod
4 lines
49 B
Modula-2
Raw
Permalink
Normal View
History
Unescape
Escape
rename to clog (#6) * rename to clog Signed-off-by: Jason Hall <jason@chainguard.dev> * fix example in README Signed-off-by: Jason Hall <jason@chainguard.dev> --------- Signed-off-by: Jason Hall <jason@chainguard.dev>
2024-01-16 12:28:27 -06:00
module
github
.
com
/
chainguard
-
dev
/
clog
Initial commit
2023-12-06 16:30:36 -07:00
slogtest: demonstrate use of t.Context() (#41) Go 1.24 added [`t.Context()`](https://pkg.go.dev/testing#T.Context), which is presumably more idiomatic to use with clog than our own slogtest package. This PR adds a comment mentioning `t.Context` and demonstrates how to get `t.Context` to have the same behavior as `slogtest.Context(t)`. Without the `slog.SetDefault` the behavior is different: ``` go test -trimpath ./slogtest -run=SlogTest -v === RUN TestSlogTest slogtest.go:36: level=INFO source=github.com/chainguard-dev/clog/slogtest/slogtest_test.go:13 msg="hello world" foo=bar slogtest.go:36: level=INFO source=github.com/chainguard-dev/clog/slogtest/slogtest_test.go:14 msg="me again" bar=baz slogtest.go:36: level=INFO source=github.com/chainguard-dev/clog/slogtest/slogtest_test.go:15 msg="okay last one" baz=true slogtest.go:36: level=DEBUG source=github.com/chainguard-dev/clog/slogtest/slogtest_test.go:17 msg="hello debug" slogtest.go:36: level=INFO source=github.com/chainguard-dev/clog/slogtest/slogtest_test.go:18 msg="hello info" slogtest.go:36: level=WARN source=github.com/chainguard-dev/clog/slogtest/slogtest_test.go:19 msg="hello warn" slogtest.go:36: level=ERROR source=github.com/chainguard-dev/clog/slogtest/slogtest_test.go:20 msg="hello error" slogtest.go:36: level=INFO source=github.com/chainguard-dev/clog/slogtest/another_test.go:9 msg="hello from fn" foo=bar --- PASS: TestSlogTest (0.00s) === RUN TestSlogTestTContext 2025/07/08 12:29:28 INFO hello world foo=bar 2025/07/08 12:29:28 INFO me again bar=baz 2025/07/08 12:29:28 INFO okay last one baz=true 2025/07/08 12:29:28 INFO hello info 2025/07/08 12:29:28 WARN hello warn 2025/07/08 12:29:28 ERROR hello error 2025/07/08 12:29:28 INFO hello from fn foo=bar --- PASS: TestSlogTestTContext (0.00s) PASS ok github.com/chainguard-dev/clog/slogtest 0.211s ``` (debug logs are dropped, no file paths or line numbers, timestamps are added) I don't know whether we should officially deprecate `slogtest` in favor of `clog.FromContext(t.Context())`, but at least this documents an off-ramp. Signed-off-by: Jason Hall <jason@chainguard.dev>
2025-08-30 21:11:13 -04:00
go
1.24
.
4
Copy permalink