Skip to content

Commit

Permalink
Fix logs in handlers
Browse files Browse the repository at this point in the history
  • Loading branch information
loicgreffier committed Nov 24, 2024
1 parent dc38734 commit 55c5ccb
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,9 @@ public class CustomDeserializationExceptionHandler implements DeserializationExc
public DeserializationHandlerResponse handle(ErrorHandlerContext context,
ConsumerRecord<byte[], byte[]> record,
Exception exception) {
log.warn("Exception caught during deserialization: taskId = {}, topic = {}, partition = {}, offset = {}",
context.taskId(),
log.warn("Exception caught during deserialization: "
+ "processorNodeId = {}, topic = {}, partition = {}, offset = {}",
context.processorNodeId(),
context.topic(),
context.partition(),
context.offset(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,15 @@
@Slf4j
public class CustomProcessingExceptionHandler implements ProcessingExceptionHandler {
@Override
public ProcessingHandlerResponse handle(ErrorHandlerContext errorHandlerContext,
public ProcessingHandlerResponse handle(ErrorHandlerContext context,
Record<?, ?> record,
Exception exception) {
log.warn("Exception caught during processing: key = {}, value = {}",
record != null ? record.key() : null,
record != null ? record.value() : null,
log.warn("Exception caught during processing: "
+ "processorNodeId = {}, topic = {}, partition = {}, offset = {}",
context.processorNodeId(),
context.topic(),
context.partition(),
context.offset(),
exception
);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,9 @@ public ProductionExceptionHandlerResponse handle(ErrorHandlerContext context,
ProducerRecord<byte[], byte[]> record,
Exception exception) {
if (exception instanceof RecordTooLargeException) {
log.warn("Record too large exception caught during production: topic = {}, partition = {}, offset = {}",
log.warn("Record too large exception caught during production: "
+ "processorNodeId = {}, topic = {}, partition = {}, offset = {}",
context.processorNodeId(),
context.topic(),
context.partition(),
context.offset(),
Expand All @@ -27,7 +29,9 @@ public ProductionExceptionHandlerResponse handle(ErrorHandlerContext context,
return ProductionExceptionHandlerResponse.CONTINUE;
}

log.warn("Exception caught during production: topic = {}, partition = {}, offset = {}",
log.warn("Exception caught during production: " +
"processorNodeId = {}, topic = {}, partition = {}, offset = {}",
context.processorNodeId(),
context.topic(),
context.partition(),
context.offset(),
Expand Down

0 comments on commit 55c5ccb

Please sign in to comment.