zerodriver icon indicating copy to clipboard operation
zerodriver copied to clipboard

Proposal: use Labels command more than once

Open kitagry opened this issue 4 years ago • 1 comments

Currently, Labels returns *zerolog.Event. So, we can't call Labels command more than once. I want to do it as follows. Do you think about this?

// prepare common label
commonLogger := logger.Info().Labels(zerodriver.Label("label", "common"))

commonLogger.Labels("phase", "1").Msg("hoge")
commonLogger.Labels("phase", "2").Msg("fuga")

kitagry avatar May 14 '21 09:05 kitagry

Thanks for your suggestion! I agree with your idea, too, but there is a problem of go's receiver specification (you cannot add methods on a receiver defined in different package). Also, if Lables returns zerodriver.Event, then you cannot call Msg or other zerolog's methods.

Do you have any idea to solve this problem?

hirosassa avatar May 14 '21 12:05 hirosassa