Skip to content
This repository has been archived by the owner on Sep 29, 2024. It is now read-only.

Migrating logging to the slog package #607

Merged
merged 4 commits into from
Aug 21, 2023

Conversation

grahamjenson
Copy link
Contributor

structured logging will soo be part of core Golang in the slog package golang/go#56345

This migrates the logging to that package, removing the dependency on the third party zap package. Zap can still be used with slog, but that decision should be on the importing project not the library.

Graham

@erkie
Copy link
Collaborator

erkie commented Aug 21, 2023

How does this PR affect the log output? Do you have an example, pre-this-PR and what this PR outputs? Are they similar? Also, how does this affect the following things that previously worked:

GO_SOCKET_IO_LOG_LEVEL="error"
GO_SOCKET_IO_LOG_ENABLE="false"
GO_SOCKET_IO_DEBUG="false"

As mentioned in logging/README.md?

Just want to understand how much of a breaking change this is.

@grahamjenson
Copy link
Contributor Author

I think this will be a breaking change because the log level should be decided by the importer of the package, but package level logging should still be configurable.

I will look at this soon.

@grahamjenson
Copy link
Contributor Author

The envars wont work (unless the importer sets them up to) but I added back the readme and put in it a small bit about how to customize the logging with slog from this package. The core problem is that a slog logger can have multiple handlers at different levels.

I think this will be a breaking change, even if not functional. I think the only way to make it not breaking would be to set as the default slog handler as a wrapper around the previous zap logger (not sure how difficult this will be), and bring back all that code as "soon to be deprecated". That is a lot of work though and we would lose the benefits of dropping two libraries and having a much simpler logging setup.

@erkie
Copy link
Collaborator

erkie commented Aug 21, 2023

Imo it's not that important that the functionality stays 100% the same, just that there is an easy way for the user of this library to customize the log levels. And the added documentation helps a lot with that! Great work.

@erkie erkie merged commit 497cb12 into googollee:master Aug 21, 2023
0 of 6 checks passed
@RandalTeng
Copy link

Thanks for your works.
Little question: when this feature will release as a public version? Like v1.17.1?

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants