-
Notifications
You must be signed in to change notification settings - Fork 86
Closed
Description
I'm working on implementing a SlogSink for another logger and looked to funcr for guidance on how to handle certain cases with groups but found that it behaves unexpectedly.
I added the following lines to ExampleToSlogHandler
:
slogLogger.WithGroup("a").Info("single empty group")
slogLogger.WithGroup("a").WithGroup("b").Info("chained empty groups")
slogLogger.WithGroup("a").WithGroup("b").With("str", "abc").Info("first group empty")
slogLogger.WithGroup("a").With("str", "abc").WithGroup("b").Info("last group empty")
slogLogger.WithGroup("a").With("str", "abc").WithGroup("b").WithGroup("c").With("x", 1).Info("middle group empty")
The output I got was:
"level"=0 "msg"="single empty group"
"level"=0 "msg"="chained empty groups"}
"level"=0 "msg"="first group empty" "b"={"str"="abc"}}
"level"=0 "msg"="last group empty" "a"={"str"="abc"}
"level"=0 "msg"="middle group empty" "a"={"str"="abc" "c"={"x"=1}}}
Apart from the trailing curly brackets I expected funcr to behave like a slog.TextHandler
, so something like:
"level"=0 "msg"="single empty group"
"level"=0 "msg"="chained empty groups"
"level"=0 "msg"="first group empty" "a"={"b"={"str"="abc"}}
"level"=0 "msg"="last group empty" "a"={"str"="abc"}
"level"=0 "msg"="middle group empty" "a"={"str"="abc" "b"={"c"={"x"=1}}}
I'm assuming the omission of the intermediate group is causing the trailing }
problem.