Field should become a type instead of an interface
nhooyr opened this issue · 3 comments
nhooyr commented
Type's should not be able to define their default logging key. I can easily see this causing bugs and would prefer the consistent explicit style of always writing out the key. If its getting duplicated a lot, With
is probably needed instead.
nhooyr commented
In fact, we could just turn Field into type struct F { Name string; Value interface{} }
and also remove slog.F
as is, reducing the API surface area further. This would go nicely with #47 as fields would be predominately specified with {
now instead of (
.
nhooyr commented
This is an example of how logging would look:
slogtest.Info(t, "my message here",
slog.F{"field_name", "something or the other"},
slog.F{"field_name", "something or the other"},
slog.F{"some_map", slog.Map{
{"nested_fields", "wowow"},
}},
slog.Error(xerrors.Errorf("wrap1: %w",
xerrors.Errorf("wrap2: %w",
io.EOF),
)),
)