2026/8/7 15:57:25 Go 用 slog 打结构化日志:分级、上下文字段与自定义 Handler 实战
Go 用 slog 打结构化日志:分级、上下文字段与自定义 Handler 实战
线上出了问题,你 grep 日志想按 user_id 把一次请求的所有日志串起来,结果发现日志长这样:
2026/08/07 09:12:33 order created for user 8812 amount 199.00
2026/08/07 09:12:33 payment failed: gateway t…