From 51f77581bcf2d1e351013aa08677943f0b203f6a Mon Sep 17 00:00:00 2001 From: Vasiliy Tolstov Date: Wed, 20 Jan 2021 22:16:59 +0300 Subject: [PATCH] move trace log to condition Signed-off-by: Vasiliy Tolstov --- segmentio.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/segmentio.go b/segmentio.go index 4cb4b01..883bdf1 100644 --- a/segmentio.go +++ b/segmentio.go @@ -207,10 +207,10 @@ func (k *kBroker) Publish(ctx context.Context, topic string, msg *broker.Message wCtx = ctx } err = writer.WriteMessages(wCtx, kmsg) - if k.opts.Logger.V(logger.TraceLevel) { - k.opts.Logger.Tracef(k.opts.Context, "write message err: %v", err) - } if err != nil { + if k.opts.Logger.V(logger.TraceLevel) { + k.opts.Logger.Tracef(k.opts.Context, "write message err: %v", err) + } switch cached { case false: // non cached case, we can try to wait on some errors, but not timeout