-
Notifications
You must be signed in to change notification settings - Fork 24
Add JSON logging support using Go's slog library #126
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
Conversation
|
Would it better to deprecate |
Maybe when we upgrade to 1.21? |
|
I'd love to get this or a similar functionality merged (I haven't reviewed the code yet). Structured logging is one of the most requested features in STUNner given how pretty much everything in the Kubernetes ecosystem is built around this logging style. Maybe we could save this PR by using/writing some That being said, deprecating pion/logging would put a pretty high burden on upstream projects that depend on it. I'm not saying we shouldn't do that, but I believe we should definitely have some smoother upgrade path in place before we make that move, like the compatibility layer suggested in this PR. |
I like this idea, I can contribute to this, if we go with this idea. |
|
@ChaturvediShilpa Hello we upgraded to go 1.21, do you wanna get this merged? |
182e355 to
438adda
Compare
JoTurk
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you want to fix the errors in the compile example so we can merge this? otherwise i can fix them myself.
Thank you.
json_logger.go
Outdated
| // Create structured log entry | ||
| attrs := []any{ | ||
| "scope", jl.scope, | ||
| "level", jl.pionLevelToString(jl.logLevelToPionLevel(level)), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wouldn't this lead to duplicated levels?
438adda to
13a6fdf
Compare
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #126 +/- ##
==========================================
- Coverage 98.33% 88.36% -9.97%
==========================================
Files 2 3 +1
Lines 120 275 +155
==========================================
+ Hits 118 243 +125
- Misses 1 24 +23
- Partials 1 8 +7
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
e3b8ae9 to
76ffa05
Compare
- Add structured JSON logging for all log levels - Update documentation with usage examples - Require Go 1.21+ for slog library support Users can now choose between text and JSON logs while maintaining the same API and functionality.
fd09553 to
99df69b
Compare
1d4cbe0 to
d5223fe
Compare
d5223fe to
af0ba73
Compare
|
Overall, I really like this. I think the Apart, I think (to the extent I could review the code) this can be merged. |
|
@rg0now yeah we talked (me and @philipch07 ) about making sure that JSONLoggerFactory is LoggerFactory before merging this. @philipch07 asked me to do it and i was doing it tonight. |
|
Also making all the unnecessary interfaces / structs private. |
|
@philipch07 @rg0now I pushed a commit to private everything that we don't need, added a LoggerFactory interface, made sure we make LeveledLogger. can you please give it a review when you have time? |
|
Thanks for cleaning it up! It looks good to me :) |
|
@rg0now does this look good to you? |
|
@rg0now I'm going to test the logging factory again before tagging this, but i think it should be drop in replacement now. thank you @ChaturvediShilpa @philipch07 |
|
Sorry, missed this thread. This was a long-standing issue and I'm really happy it finally got fixed. Thanks! |
This change allows users to choose between text and JSON logging formats while maintaining the same API and functionality.
Description
Reference issue
Closes #127