作者 唐旭辉

调测

@@ -154,19 +154,19 @@ func (r *Runer) Start(ctx context.Context) { @@ -154,19 +154,19 @@ func (r *Runer) Start(ctx context.Context) {
154 select { 154 select {
155 case msg, more := <-r.Consumer.Messages(): 155 case msg, more := <-r.Consumer.Messages():
156 if more { 156 if more {
157 - fmt.Printf("Partition:%d, Offset:%d, Key:%s, Value:%s Timestamp:%s\n", msg.Partition, msg.Offset, string(msg.Key), string(msg.Value), msg.Timestamp) 157 + logs.Info("Partition:%d, Offset:%d, Key:%s, Value:%s Timestamp:%s\n", msg.Partition, msg.Offset, string(msg.Key), string(msg.Value), msg.Timestamp)
158 r.Consumer.MarkOffset(msg, "") // mark message as processed 158 r.Consumer.MarkOffset(msg, "") // mark message as processed
159 } 159 }
160 case err, more := <-r.Consumer.Errors(): 160 case err, more := <-r.Consumer.Errors():
161 if more { 161 if more {
162 - fmt.Println("Kafka consumer error: %v", err.Error()) 162 + logs.Info("Kafka consumer error: %v", err.Error())
163 } 163 }
164 case ntf, more := <-r.Consumer.Notifications(): 164 case ntf, more := <-r.Consumer.Notifications():
165 if more { 165 if more {
166 - fmt.Println("Kafka consumer rebalance: %v", ntf) 166 + logs.Info("Kafka consumer rebalance: %v", ntf)
167 } 167 }
168 case <-ctx.Done(): 168 case <-ctx.Done():
169 - fmt.Errorf("Stop consumer server...") 169 + logs.Info("Stop consumer server...")
170 r.Consumer.Close() 170 r.Consumer.Close()
171 return 171 return
172 } 172 }