Git Product home page Git Product logo

Comments (4)

peterbourgon avatar peterbourgon commented on July 23, 2024

@ChrisHines what do you think?

 if len(keyvals)%2 != 0 {
-    panic("bad keyvals")
+    keyvals = append(keyvals, "(MISSING)")
 }

from kit.

husio avatar husio commented on July 23, 2024

I don't have any preferences here. I think (MISSING) is easier to spot when browsing logs than empty string or nil.
👍

from kit.

tsenart avatar tsenart commented on July 23, 2024

+1

from kit.

ChrisHines avatar ChrisHines commented on July 23, 2024

I agree that we should remove these panics.

In logfmt.MarshalKeyvals I appended nil in this scenario. That package logs a nil value the same as JSON (i.e. "null").

At the slightly higher level of abstraction here in the log package it seems reasonable to provide a more helpful indicator. I would also like to make it easy for applications to control how a missing value is ultimately handled, so I don't like a "magic" string.

I propose adding an exported error variable that is appended and can be checked by a downstream logger if a different behavior is desired.

var ErrMissingValue interface{} = errors.New("(MISSING)")

from kit.

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.