-
-
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
Switch to slog for structured logging #144
base: main
Are you sure you want to change the base?
Conversation
Hi @dennwc . I would see maybe this as big shift. |
Note of possible drop performance |
Indeed, this is something that needs a longer discussion. I opened a PR instead of the issue because we already have it implemented in LiveKit's branch of sipgo that we use. We would really like to upstream the changes we have and switch to upstream.
Definitely! No rush, please take your time. The conversion was 1:1, except a few places where the log calls were adding some common parameter. I rewrote those places to share a common logger var (e.g. in TXes) that sets logging parameters upfront (
I'm totally okay with updating this PR from time to time while the PR is in review.
I totally understand your concern about having to switch the logging library in other projects. But I assure you, you won't need to switch away from zerolog in other projects. Calling This is the main reason for this change, actually. We use Zap internally, and also are hesitant to switch to a different logger or have to configure multiple loggers. With this change, any structured logger can be used without conflicts.
Correct, comparing to zerolog, there will be a minor performance hit. From what I understand, it's mostly due to calls to In general, if you are concerned about logging performance in sipgo, there are other low-hanging fruits for improving performance. For example, calls to Same is true for this PR as well - it's not ideally optimized. It passes logging parameters as |
hey @dennwc do you mind opening this as issue? |
Sure, I can do it, but it would be just a copy-paste from a discussion here. PR might be better IMHO, because here we can discuss specific implementation details, benchmark it, etc. I could update/rebase the PR as well, if you like. |
Currently, sipgo uses zerolog for structured logging. Even though this is one of the fastest structured loggers, there are other alternatives that upstream projecs may use (e.g. zap).
This change switches sipgo to stdlib's
log/slog
package, which can be configured by the developer to use any existing logger implementation:Using a single logger implementation between sipgo and the main application allows attaching relevant SIP logging context to the high-level application logs.