-
Notifications
You must be signed in to change notification settings - Fork 46
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
[Chore] Add functions required for single logger instance #297
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@khushijain21 for the function which need docs, if the doc would be the same as for the non-local version you can refer to the non-local and point out the difference. Like that:
// SomeFunction performs a specific operation and logs relevant information using the global logger.
//
// It takes an input string and processes it, logging the input and the result of the processing.
func SomeFunction(input string) string {
// SomeFunctionLocal is the same as SomeFunction but returns a logger instance instead.
func SomeFunctionLocal(input string, logger *log.Logger) (string, *log.Logger) {
With new local methods, we will lose the observerLogs parameter available on global config. Unless we change Logger struct to include
This would change many API's that depend on Instead, users can get similar functionality with this
Any thoughts? I prefer going with the second option. |
I like the second option too. First option would require a testing-only struct field wich does not make much sense for production code. Second option is more pluggable as well. |
@khushijain21 I thought If we change all our interfaces to accept a local logger, testing should also do so and everything should be recorded in the local logger instead. |
Yes it is used only for testing. It is used in 9 files in beats https://github.com/search?q=repo%3Aelastic%2Fbeats%20ObserverLogs&type=code
Yes, so users can create an observer core and access "testing logs" on the local logger. As described on the second part here #297 (comment) |
I'd really like @belimawr to take a look before we merge. I think it is safe since we are only adding functions, but logp has a history of unexpected behavior. |
Co-authored-by: Mauri de Souza Meneguzzo <mauri870@gmail.com>
Co-authored-by: Tiago Queiroz <me@tiago.life>
Co-authored-by: Tiago Queiroz <me@tiago.life>
💚 Build Succeeded
History
|
What does this PR do?
Required for https://github.com/elastic/ingest-dev/issues/5251
This PR adds some existing methods (on
logp
package) but withLocal
appended to the method name. These are required bylibbeat
to use single logger instance. It does not remove any existing methods not to break any code dependent on thelogp
libraryWhy is it important?
Checklist
Related issues