GithubHelp home page GithubHelp logo

Comments (14)

pohly avatar pohly commented on June 23, 2024

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.

thockin avatar thockin commented on June 23, 2024

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.

pohly avatar pohly commented on June 23, 2024

That's in zapr.go, our own code. We could change the keys if we wanted to.

zapr/zapr.go

Line 93 in a332506

l.DPanic("strongly-typed Zap Field passed to logr", zap.Any("zap field", args[i]))

from zapr.

thockin avatar thockin commented on June 23, 2024

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.

thockin avatar thockin commented on June 23, 2024

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.

pohly avatar pohly commented on June 23, 2024

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.

thockin avatar thockin commented on June 23, 2024

@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.

pohly avatar pohly commented on June 23, 2024

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.

thockin avatar thockin commented on June 23, 2024

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.

pohly avatar pohly commented on June 23, 2024

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.

pohly avatar pohly commented on June 23, 2024

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.

thockin avatar thockin commented on June 23, 2024

from zapr.

pohly avatar pohly commented on June 23, 2024

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.

pohly avatar pohly commented on June 23, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.