EventStore / EventStore-Client-Go

Go Client for Event Store version 20 and above.
Apache License 2.0
105 stars 27 forks source link

Make logging pluggable #117

Closed marcinbudny closed 2 years ago

marcinbudny commented 2 years ago

Currently there is no way to control logging from the ESDB client. E.g. these messages are written to console in my application:

2022/04/14 20:51:27 [info] discovery attempt 1/10
2022/04/14 20:51:27 [debug] trying candidate 'localhost:2113'...
2022/04/14 20:51:27 [debug] Attempting node supported features retrieval on 'localhost:2113'...
2022/04/14 20:51:27 [debug] Retrieved supported features on node 'localhost:2113' successfully

It would be great to make the logging pluggable, so that the user of the library can decide where the logs are written and select the logging level.

YoEight commented 2 years ago

@marcinbudny Do you have a library that you like on this? I'm not a Gopher so I'm looking for examples.

marcinbudny commented 2 years ago

I'm currently using logrus, however I don't think adding a specific logger to ESDB client is the way to go. ESDB client is a library and it should enable its users to choose what they want to use.

If there was an abstraction layer for logging, I could implement a simple adapter for logrus. This abstraction layer could be something similar to the one proposed in this repo. This is just an example, instead of adding it as a dependency, ESDB client could define its own logging interface.

The default implementation could write to console, but then I could replace it with my implementation that writes to logrus.

BTW I'm not a Gopher myself, so maybe there is a more idiomatic way to do this 😉

YoEight commented 2 years ago

@marcinbudny if possible, I'd like to have your input on https://github.com/EventStore/EventStore-Client-Go/pull/119

The PR brings a pluggable logging implementation based on a function type.