-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
Add a slightly slower, but less verbose, logger #138
Comments
This issue seems unwarranted to me, for the following reason. Rather than sprinkle ad-hoc strings around the code for the field names, I think it is better to wrap all fields to be logged in some trivial functions, which I define in one place, e.g.
This has these benefits:
So, with this approach, I log an event as follows:
What do you think? |
@tesujimath While I agree that the scheme you've proposed is reasonable, I don't think it affects this issue. This issue is about adding an optional wrapper around the main If that API isn't to your taste, don't use the wrapper ;) |
@akshayjshah I'm afraid I don't see the use for the sugared API. You mention verbosity again, but the scheme I propose has the same verbosity as the sugared approach (it's just faster and safer). If the goal is to support ad-hoc logging, with unplanned field names, I concede the sugared API is better in that respect. ;-) But I don't really see how anyone would process their logfile without having a record somewhere of what fields it may contain. (Just like with unstructured logging.) Of course anyone can write a sugared API wrapper, and I don't really care. But would you at least be open to a pull request for a new section in the README describing my scheme? So that anyone who is thinking of using the sugared API at least understands the other option. |
@tesujimath We'll have to agree to disagree on this. I'd prefer to keep the README and docs as-is; as the package author, I'd prefer to highlight the |
Landed on dev. |
zap.Logger
is really fast, but it's quite verbose - users must repeatedly reference thezap
package. This is a good trade-off for performance-critical applications, but it's not good for most users. Consider the impression that this snippet from the README leaves on potential users and contributors:The wrapper provided by the
zbark
sub-package is great for our internal use, since we're using thebark.Logger
interface all over. However, it's also unpleasantly verbose:To show off how easy it is to write a clean wrapper on top of the core
zap.Logger
type, spur adoption, and generally make a better impression on first-time users, I'd like to include a higher-levelzap.SugaredLogger
(name TBD - we could even rename the current logger toCoreLogger
and call the new thingLogger
). I'm open to other ideas, but I'd like something similar to thelog15
API:The text was updated successfully, but these errors were encountered: