Add Core function to logp.Logger to allow access to backing zapcore.Core.#88
Conversation
| } | ||
|
|
||
| // Core returns the backend zapcore.Core for the logger. | ||
| func (l *Logger) Core() zapcore.Core { |
There was a problem hiding this comment.
I wonder if it would be better to define a type alias like it's done with the zap.Option:
elastic-agent-libs/logp/logger.go
Lines 27 to 28 in 89215ad
I don't know how far we want to go exposing the zap types in our library. I see that the Logger struct just has zap types directly:
elastic-agent-libs/logp/logger.go
Lines 30 to 34 in 89215ad
There was a problem hiding this comment.
Don't see a need to hide it. It is zap and zapcore under the hood and the go.mod for any project that imports elastic-agent-libs will show zap and zapcore.
There was a problem hiding this comment.
It would rather an abstraction should we decide to switch from zap to something else. I guess that's the point. But I'm okay with this.
What does this PR do?
Adds the ability to retrieve the
zapcore.Corefrom thelogp.Logger. This allows the ability to write entries directly into the logger bypassing any log levels settings.Why is it important?
This is needed for the work on elastic/elastic-agent#221. The
io.Writerconnected tostdoutandstderrfrom the spawned subprocesses will read the output from the process and output it directly to thezapcore.Core. That is required because each component and unit can have its own log level different from the Elastic Agent log level. Because of that design it requires that log messages bypass the log level settings for the logger used by Elastic Agent.Checklist
[ ] I have added tests that prove my fix is effective or that my feature worksCHANGELOG.mdRelated issues