-
Notifications
You must be signed in to change notification settings - Fork 0
/
doc.go
22 lines (15 loc) · 834 Bytes
/
doc.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
/*
Package slogjson lets you format your Golang structured logging [log/slog] usingthe JSON v2
library [github.com/go-json-experiment/json], with optional single-line pretty-printing.
This is so much easier to read than the default json:
{"time":"2000-01-02T03:04:05Z", "level":"INFO", "msg":"m", "attr":{"nest":1234}}
or
{"time": "2000-01-02T03:04:05Z", "level": "INFO", "msg": "m", "attr": {"nest": 1234}}
Versus the default standard library JSON Handler:
{"time":"2000-01-02T03:04:05Z","level":"INFO","msg":"m","attr":{"nest":"1234"}}
Additional benefits:
* JSON v2 is faster than the stdlib JSON v1 (up to 9x faster).
* Can make use of all marshaling and encoding options JSON v2 has available.
* Improved correctness and behavior with JSON v2. See: https://github.com/golang/go/discussions/63397
*/
package slogjson