-
Notifications
You must be signed in to change notification settings - Fork 79
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
funcr: slog output omits intermediate groups #273
Comments
What I see is:
Oh, looking closely I do see this. huh. I think you punched a hole in my pre-render-everything approach. To my own defense, we pass I will have to think about how to solve this. |
I figured it out:
I will have to craft a test to cover this, which I can try to do tomorrow. |
I looked into creating a golang issue and noticed that
Which is this test case: https://github.com/golang/go/blob/go1.22.0/src/testing/slogtest/slogtest.go#L161 |
Weird, when I run 1.22 I see the test fail, but when I look at the output
generated I see `{"logger":"slog","ts":"2024-03-01
08:27:53.763813","caller":{"file":"main_slog.go","line":42},"level":0,"msg":"msg","mode":"slog","a":"b","G":{"c":"d"}}`
…On Fri, Mar 1, 2024 at 3:00 AM Mario Valderrama ***@***.***> wrote:
I looked into creating a golang issue and noticed that
TestRunSlogTestsOnSlogHandlerLogSink fails on go 1.22. Both on master and
your PR @thockin <https://github.com/thockin>.
slog.go:62: Unexpected error: missing group "G": a Handler should not output groups if there are no attributes
Which is this test case:
https://github.com/golang/go/blob/go1.22.0/src/testing/slogtest/slogtest.go#L161
—
Reply to this email directly, view it on GitHub
<#273 (comment)>, or
unsubscribe
<https://github.com/notifications/unsubscribe-auth/ABKWAVBTXXJLDR56IBABLY3YWBNTVAVCNFSM6AAAAABD6MZKQWVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTSNZSHE3TQMJTGY>
.
You are receiving this because you were mentioned.Message ID:
***@***.***>
|
Yeah, the tescase seems broken - I have the right output. Will investigate later. |
OK. The test fail on 1.22 is because they added a new testcase that our slog handler adapter doesn't cover. Go should add a testcase for nested groups and trailing "empty" groups, I think. funcr itself passes slogtest right now, but it should not. |
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
:The output I got was:
Apart from the trailing curly brackets I expected funcr to behave like a
slog.TextHandler
, so something like:I'm assuming the omission of the intermediate group is causing the trailing
}
problem.The text was updated successfully, but these errors were encountered: