Skip to content

Commit 2727a07

Browse files
committed
Merge pull request #405 from dpkp/log_error_type
Log response error types in consumer and producer logs
2 parents 4dec5d3 + 942c693 commit 2727a07

File tree

2 files changed

+11
-7
lines changed

2 files changed

+11
-7
lines changed

kafka/consumer/simple.py

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -358,23 +358,26 @@ def _fetch(self):
358358
try:
359359
check_error(resp)
360360
except UnknownTopicOrPartitionError:
361+
log.error('UnknownTopicOrPartitionError for %s:%d',
362+
resp.topic, resp.partition)
361363
self.client.reset_topic_metadata(resp.topic)
362364
raise
363365
except NotLeaderForPartitionError:
366+
log.error('NotLeaderForPartitionError for %s:%d',
367+
resp.topic, resp.partition)
364368
self.client.reset_topic_metadata(resp.topic)
365369
continue
366370
except OffsetOutOfRangeError:
367-
log.warning("OffsetOutOfRangeError for %s - %d. "
368-
"Resetting partition offset...",
371+
log.warning('OffsetOutOfRangeError for %s:%d. '
372+
'Resetting partition offset...',
369373
resp.topic, resp.partition)
370374
self.reset_partition_offset(resp.partition)
371375
# Retry this partition
372376
retry_partitions[resp.partition] = partitions[resp.partition]
373377
continue
374378
except FailedPayloadsError as e:
375-
log.warning("Failed payloads of %s"
376-
"Resetting partition offset...",
377-
e.payload)
379+
log.warning('FailedPayloadsError for %s:%d',
380+
e.payload.topic, e.payload.partition)
378381
# Retry this partition
379382
retry_partitions[e.payload.partition] = partitions[e.payload.partition]
380383
continue

kafka/producer/base.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -166,8 +166,9 @@ def _handle_error(error_cls, request):
166166

167167
if error_cls:
168168
_handle_error(error_cls, orig_req)
169-
log.error('Error sending ProduceRequest (#%d of %d) to %s:%d '
170-
'with msgs %s', i + 1, len(requests),
169+
log.error('%s sending ProduceRequest (#%d of %d) '
170+
'to %s:%d with msgs %s',
171+
error_cls.__name__, (i + 1), len(requests),
171172
orig_req.topic, orig_req.partition,
172173
orig_req.messages if log_messages_on_error
173174
else hash(orig_req.messages))

0 commit comments

Comments
 (0)