Skip to content
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

[go] Allow user-defined Logger #531

Open
raskyld opened this issue Nov 30, 2024 · 2 comments
Open

[go] Allow user-defined Logger #531

raskyld opened this issue Nov 30, 2024 · 2 comments

Comments

@raskyld
Copy link

raskyld commented Nov 30, 2024

The Go ecosystem has a lot of opinionated logger, slog is indeed the one proposed by the standard library, it is good for general-purpose application but may fall short for high-performance applications.

If you are okay with that, I may contribute to wRPC Go codebase by allowing users to pass custom Loggers using the API of https://github.com/go-logr/logr so they integrate better with:

  • The NATS Client wrapper,
  • The generated bindings,

WDYT?

@rvolosatovs
Copy link
Member

It appears that logr and slog are interoperable: https://github.com/go-logr/logr?tab=readme-ov-file#slog-interoperability

I'm not sure that we want to depend on anything outside the standard library and wRPC Go module in the generated bindings.

Are calls like slog.Debug (e.g.

slog.Debug("reading string length")
) the issue here?

If so, perhaps we could introduce an interface mimicking slog API and a global logger variable in wRPC Go module with setters and getters, which would allow users to customize this?

@raskyld
Copy link
Author

raskyld commented Dec 3, 2024

That sounds like a really good idea indeed, and I also understand your concerns about expanding the dependencies.
Let's do our own custom interface so! Just we need to think about how we can make this interface support structured logging then..

I am pretty surprised the standard library doesn't have already an API.. that would have been really handy..

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

No branches or pull requests

2 participants