Switch from glog to slog for structured (as well as leveled) logging
Opened this issue · 0 comments
scr-oath commented
slog wins
- slog is now part of the SDK, maintained by the language owners
- slog has support for OpenTelemetry bridging
- slog has json format and, can log any structure in attributes
- There are some nice libraries already https://github.com/samber/slog-multi and https://github.com/samber/slog-sampling e.g. to duplicate, route, or sample logs.
glog shortcomings
- glog has issue with write size - it converts newlines to
\n
for only as big as will fit in its buffer; beyond that, all newlines are as-is and cause multiple, disjoint, possibly interleaved lines to be written. - glog's format does not support things like json for log collectors (like google cloud observability suite, that can query them with BigQuery log analytics)