3 ms·
Wouldn't the signature of the tagged logging function be better if it was something like: DebugWithTags(message string, tags ...string) This way you coul
by jzelinskie 12y ago
Wouldn't the signature of the tagged logging function be better if it was something like:
DebugWithTags(message string, tags ...string)
This way you could easily add tags without having to explicitly allocate a []string whenever you wanted to change them.
- pythonist 12y ago+1 :)
- fizzbatter 12y agoPerhaps it depends on how much content you're putting into the message, normally? Eg, big multi-line strings, followed by more args at the end, is not a syntax i personally prefer. With that said, i really do wish Go supported `DebugWithTags(tags ...string, message string)` syntax. I've had so many cases where i wanted to use something similar.
- kornish 12y agoFor the record, if the last argument of a Golang function is variadic, you can still pass an array to it - you just have to transform the array into variadic args by appending `...` to it. So adopting the type signature above could give you the best of both worlds - the ability to use one-off tag combinations inline, but also the ability to pass predefined arrays of tags.
- fizzbatter 12y agoI hadn't actually seen their Code, it looks like they actually use `DebugWithTags([]string, string, ...interface{})`. So the `...interface{}` is the blocker here, as it appears in every logger that they have. Though, i would agree that the order should be switched. Eg, `DebugWithTags(string, []string, ...interface{})`
- blakecaldwell 12y agoIt's more consistent with the printf-style counterparts: func (logger *LoggerImpl) DebugWithTagsf(tags []string, fmt string, args ...interface{}) { logger.logwithformat(DEBUG, tags, fmt, args...) }
- mmf 12y agoI think that function is meant to set the debug level, not to produce a log output...