|
|
|
|
|
by reggieband
1374 days ago
|
|
I don't care about the formatting, I care about the available data types. JSON is just easy to use since it includes arrays/hash-tables and it is already supported by a large number of tools. If you look at the Attr type definition you can see they support many primitive types including Int, Float, Bool, String, Duration, and Time. So if I had a record type, like a customer I could do: slog.LogAttrs(slog.ErrorLevel, "oops",
slog.Int("customer_id", 123456),
slog.Float("customer_balance", 12.42)
slog.Time("customer_updated_at", ...))
But I would prefer a structured data type there. Something more like: { "customer": {
"id": 123456,
"balance": 12.42
"updated_at": ...
}
}
In fact, I'm not sure how I'd go about supporting arrays as Attr except with keys like "item_0", "item_1", etc. Or maybe serialize it into a representation like comma separated values. But now I'm coupling my log to a custom serialization/deserialization - I'd rather just use JSON once again since most tools will know how to handle it. |
|