Comments (14)
Should and can those fields be renamed?
I've not seen a recommendation how to handle keys that consist of multiple words. zapField
or zap-field
or ... ?
from zapr.
I don't know if zap allows us to change these. JSON allows keys with spaces, we just documented this as a convention for easiest consumption. It's probably not very consequential.
from zapr.
That's in zapr.go, our own code. We could change the keys if we wanted to.
Line 93 in a332506
from zapr.
I question the value of DPanic from within this lib. Disallowing zap.Field is weird. That's not our business. Input errors should not generate additional log-lines IMO, though I can see value to "panic on ill-formed log-lines in debug mode"
from zapr.
But if we DO keep it, I think it's fine to change the keys.
Watch out or you'll end up a maintainer of this :)
from zapr.
I question the value of DPanic from within this lib. Disallowing zap.Field is weird. That's not our business.
I'm on the edge myself. It breaks portability of the code which calling the logger with such a parameter, but perhaps someone doesn't care and/or wants to do it when knowing that the logger is a zap logger.
Input errors should not generate additional log-lines IMO, though I can see value to "panic on ill-formed log-lines in debug mode"
I like the idea of making those panic messages conditional on a debug flag. Then the caller can decide.
@DirectXMan12 you originally wrote that code - any thoughts on this? ^^^
But if we DO keep it, I think it's fine to change the keys.
That then begs the question: what should the non-space-using-keys be? nonSpaceUsingKeys? NonSpaceUsingKeys? We can discuss here and then extend the logr recommendations. IMHO that's actually more important than updating zapr because developers will loose time when encountering this issue without getting some guidance, for example because they start looking for prior art to remain consistent.
Watch out or you'll end up a maintainer of this :)
Who, me? I have no idea what you are talking about.
from zapr.
@DirectXMan12 has found themselves mostly detached from this code, so while I welcome their input, I wouldn't block on it for too long.
nonSpaceUsingKeys? NonSpaceUsingKeys?
There's no convention that I know of. Kubernetes chose nonSpaceUsingKeys
and I hate it. It has cause so many problems with Go's conventions and godoc comments. If we have to pick I'd say "NonSpaceUsingKeys" or "non-space-using-keys"
from zapr.
Kubernetes chose nonSpaceUsingKeys and I hate it.
Where was that chosen?
It has cause so many problems with Go's conventions and godoc comments
Because keys were confused with Go code, for example in search/replace? I don't like it either, I'm just trying to understand whether it is objectively worse than the alternatives.
There's no convention that I know of.
Perfect, then we can recommend something.
If we have to pick I'd say "NonSpaceUsingKeys" or "non-space-using-keys"
I like "non-space-using-keys" better because it is consistent with existing single-word keys which use lower case ("err", "v").
from zapr.
Where was that chosen?
For all of our APIs - the canonical JSON and YAML is lowercaseUppercase
Because keys were confused with Go code, for example in search/replace?
It requires every field has a json
tag with the name (vector for cut-paste errors) and because comments can either be godoc compatible or useful in doc-gen but not both.
from zapr.
For all of our APIs - the canonical JSON and YAML is lowercaseUppercase
I see. I thought it was something specific to JSON message output, perhaps in the structured logging KEP or one of the associated documents. IMHO we can ignore this Kubernetes API convention for JSON log messages. Or side-step the question entirely by proposing "non-space-using-keys"... I'll submit a PR.
from zapr.
I found that Kubernetes has a recommendation for multi-word keys. You won't like it. Let's continue the discussion in go-logr/logr#65
from zapr.
from zapr.
They are not, but conflicting recommendations put developers into an awkward spot. I'd like to see more cooperation (see zapr fork), not less.
from zapr.
We added some recommendations to logr. We could change the keys accordingly here, but strictly speaking that might be an API break for zapr v1.0.0 (it could be that someone looks for the previous values), so let's keep everything as-is here. Simpler, too...
from zapr.
Related Issues (20)
- Package name is documented as `zapr` but is actually `zaplogr` HOT 2
- Tag a new release HOT 1
- Wrong line reported
- WithName and WithValues should preserve log level HOT 1
- Panic when using production configs and small log level HOT 5
- "stacktrace":"github.com/go-logr/zapr.(*zapLogger).Error HOT 3
- How to configured this to log to stdout, not stderr like bizarre Golang standard HOT 1
- Re-pin to a newer zap version
- Bump github.com/go-logr/logr v1.0.0-rc1 => v1.0.0 ?
- Incorrect number of arguments detected HOT 2
- Allow mapping between logr V() and zap log levels HOT 7
- DisableCaller in Zap Config HOT 1
- Why doesn't support semver spec to latest tag? HOT 4
- inconsistent logging of value vs. value embedded somewhere else HOT 2
- warn about malformed parameters HOT 1
- Logr to Zap Level Confusion HOT 3
- Data race in WithName() implementation? HOT 6
- use zap.Inline instead of allocating []zap.Field HOT 1
- Wrong line reported HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from zapr.