-
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
configure logging from a zap.Core #218
Conversation
logp/core.go
Outdated
@@ -151,6 +151,56 @@ func ConfigureWithOutputs(defaultLoggerCfg Config, outputs ...zapcore.Core) erro | |||
return nil | |||
} | |||
|
|||
// ConfigureWithCore configures the global logger to use an output created | |||
// from `defaultLoggerCfg` and all the output passed by `output`. | |||
func ConfigureWithCore(defaultLoggerCfg Config, core zapcore.Core) error { |
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.
@leehinman, I'm confused here, how is this function conceptually different from ConfigureWithOutputs
?
Even the GoDoc for it is pretty much the same :P
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.
observedLogs and the default logger output. But yes, these are very similar functions. I'm fine with saying we should refactor. The reason for opening the PR was to get you to look at it :-)
Is there a unit test that could be written for this function? |
Converted to draft PR due to PTO and I think Tiago and I need to talk through if we can just use |
77f44b4
to
729d4bd
Compare
💚 Build Succeeded
History
|
@@ -151,6 +151,48 @@ func ConfigureWithOutputs(defaultLoggerCfg Config, outputs ...zapcore.Core) erro | |||
return nil | |||
} | |||
|
|||
// ConfigureWithCore configures the global logger to use the passed in | |||
// core. It is assumed that an output has already been defined with |
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.
[NIT]
Is there any reason to use double spaces after the period?
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.
I recall seeing this in some other PRs from Lee, maybe it is an editor configuration on his side?
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.
This is just for context, since you both seem interested. I'm not getting into a flame war about white space formatting in comments.
It has to do with being old enough that I learned to type on an actual typewriter. 2 spaces between sentences were required. To see why they were required take a look at a full sheet of text in Pica 10pt (Courier is pretty close), and make sure justification is disabled. Without the 2 spaces it is very hard to scan text to see where one sentence ends and one begins. And since you are using your eyes to "search", this is a very desirable feature.
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.
LGTM, but you may want to see if Tiago still has any comments
What does this PR do?
Adds new
ConfigureWithCore
to the logp package. This allows you to use an existingzapcore.Core
instead of creating a new one. This is useful if you need to use logp within a project that has already setup azapcore.Core
on it's own.Why is it important?
Allows projects that use logp for logging to use an existing
zapcore.Core
Checklist
Author's Checklist
Related issues