Open andreimatei opened 3 years ago
I don't get it, what's wrong with log.Infof("%+v", errors.New("stack trace"))
?
Well I wouldn't have thought about that; there's two things that need to click for the writer: that errors have a stack in them and that you need to print the error with %+v in order to get the stack. That's two too many; compare to one method that gives me what I want - the stack trace as a string (no error; why am I creating an error?). It's not what the author of the code above wrote. It's also not what the authors of this or this wrote (I can probably find more).
Of course, having a debug.Stack()
wrapper by itself would not mean that people use it. But I think the chances would be better, and we can also have a lint for it I guess.
It's also not what the authors of this or this wrote (I can probably find more).
yeah this looks wrong.
Let's make a linter with some suggestions.
I'd like to bump this back up in importance.
A stack trace produced by
debug.Stack()
looks like this in the log; one can't even tell that it's a stack trace.I'm sure we print these in various places, for example here. One way or another, it'd be good for these to not be redacted. Perhaps create a wrapper for
debug.Stack()
that returns aSafeValue
?Epic: CRDB-6668
Jira issue: CRDB-6914