-
-
Notifications
You must be signed in to change notification settings - Fork 515
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
added interface for logger #385
Conversation
Just out of curiosity: why not using github.com/go-logr/logr? |
was looking for a simpler PR (adding another dependency/refactoring the existing logging in this app would need some communication/additional steps/etc) this allows anything with or whatever custom logger someone has cooked up |
As I said, just an idea! Although there are only 4 places where the logger is used anyway 😄 |
fair enough! my goal with the PR was to have a custom logger (basically an interface instead of a struct) with the smallest change possible |
TBH I do not have a strong opinion on this. I'd be more than happy with a community effort to decide where to go here :) |
What about: type TestLogger interface {
Logf(format string, args ...interface{})
// optionally:
Errorf(format string, args ...interface{})
} This is already compatible with I'd propose to get rid of the global |
Ciao! This is a highly opinionated and kind of complex topic. It is hard to get an agreement on what logging interface we should use. But we need to take a decision. I like what is proposed right now because it is simple. And looking at the logs we span today, we do not need anything complex. I understand why log level are important, but I think we can build up a sort of convention when needed passing a k/v with key=level for example. I think Having a level is important because if needed you can decide what gets forwarded to stdout and what to sderr. I would like to do with the proposed one. @baez90 wdyt? |
😄 I see, tbh I did not really think of the whole 'level' debate - I rather had in mind what consequences an error should have in a testcase when I'm starting a testcontainer and how to implement the interface as easy as possible to get the logs in my test summary. Having a distinguished case for logging errors makes it easier e.g. to build an adapter that propagates them to type Logger interface {
Info(msg string, keysAndValues ...interface{})
Error(err error, msg string, keysAndValues ...interface{})
} (which is btw. exactly the same signature as in go-logr 😄 ) But in the end I think @gianarb is totally right, the original proposal is totally fine and is open enough for everyone to implement their specific behavior based on their personal preference 😊 Edit: the longer I think about it the more I come to the conclusion that the original proposal might be a better fit. Is there a chance to include a |
Nice idea, @dhuckins do you mind to add this bit so we can proceed and merge? |
I can also provide this as part of a follow up PR. I think it could make sense to be able to optionally set the logger as part of the But independent of if this makes sense or not you could merge this PR already and further discussions could take place in a follow up so @dhuckins doesn't have to wait any longer? |
Yes we can do it as a follow up PR you are right. @baez90 yes it will be great to be able to override a logger for a specific container, probably with a function like |
sorry, have been busy last few days |
using an interface instead of the std lib struct type for the logger allows for more flexibility with users setting custom logger