Skip to content

Improve logging #190

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Mar 22, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,7 @@ void doClose() {

try {
if (!prefetchExecutor.isShutdown()) {
LOG.info("Shutting down " + SQSSession.CONSUMER_PREFETCH_EXECUTOR_NAME + " executor");
LOG.debug("Shutting down {} executor", SQSSession.CONSUMER_PREFETCH_EXECUTOR_NAME);
// Shut down executor.
prefetchExecutor.shutdown();
}
Expand All @@ -233,9 +233,8 @@ void doClose() {

if (!prefetchExecutor.awaitTermination(PREFETCH_EXECUTOR_GRACEFUL_SHUTDOWN_TIME, TimeUnit.SECONDS)) {

LOG.warn("Can't terminate executor service " + SQSSession.CONSUMER_PREFETCH_EXECUTOR_NAME +
" after " + PREFETCH_EXECUTOR_GRACEFUL_SHUTDOWN_TIME +
" seconds, some running threads will be shutdown immediately");
LOG.warn("Can't terminate executor service {} after {} seconds, some running threads will be shutdown immediately",
SQSSession.CONSUMER_PREFETCH_EXECUTOR_NAME, PREFETCH_EXECUTOR_GRACEFUL_SHUTDOWN_TIME);
prefetchExecutor.shutdownNow();
}
} catch (InterruptedException e) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -349,8 +349,7 @@ protected jakarta.jms.Message convertToJMSMessage(Message message) throws JMSExc
try {
jmsMessage = new SQSBytesMessage(acknowledger, queueUrl, message);
} catch (JMSException e) {
LOG.warn("MessageReceiptHandle - " + message.receiptHandle() +
"cannot be serialized to BytesMessage", e);
LOG.warn("MessageReceiptHandle - {} cannot be serialized to BytesMessage", message.receiptHandle(), e);
throw e;
}
} else if (SQSMessage.OBJECT_MESSAGE_TYPE.equals(messageType)) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2010-2019 Amazon.com, Inc. or its affiliates. All Rights Reserved.
* Copyright 2010-2023 Amazon.com, Inc. or its affiliates. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License").
* You may not use this file except in compliance with the License.
Expand Down Expand Up @@ -152,7 +152,7 @@ void sendInternal(SQSQueueDestination queue, Message rawMessage) throws JMSExcep

SendMessageResponse sendMessageResult = amazonSQSClient.sendMessage(sendMessageRequest.build());
String messageId = sendMessageResult.messageId();
LOG.info("Message sent to SQS with SQS-assigned messageId: " + messageId);
LOG.debug("Message sent to SQS with SQS-assigned messageId: {}", messageId);
// TODO: Do not support disableMessageID for now.
message.setSQSMessageId(messageId);

Expand Down
9 changes: 4 additions & 5 deletions src/main/java/com/amazon/sqs/javamessaging/SQSSession.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2010-2019 Amazon.com, Inc. or its affiliates. All Rights Reserved.
* Copyright 2010-2023 Amazon.com, Inc. or its affiliates. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License").
* You may not use this file except in compliance with the License.
Expand Down Expand Up @@ -405,7 +405,7 @@ void doClose() throws JMSException {

try {
if (executor != null) {
LOG.info("Shutting down " + SESSION_EXECUTOR_NAME + " executor");
LOG.debug("Shutting down {} executor", SESSION_EXECUTOR_NAME);

executor.shutdown();

Expand All @@ -419,9 +419,8 @@ void doClose() throws JMSException {

if (!executor.awaitTermination(10, TimeUnit.SECONDS)) {

LOG.warn("Can't terminate executor service " + SESSION_EXECUTOR_NAME + " after " +
SESSION_EXECUTOR_GRACEFUL_SHUTDOWN_TIME +
" seconds, some running threads will be shutdown immediately");
LOG.warn("Can't terminate executor service {} after {} seconds, some running threads will be shutdown immediately",
SESSION_EXECUTOR_NAME, SESSION_EXECUTOR_GRACEFUL_SHUTDOWN_TIME);
executor.shutdownNow();
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,9 +103,7 @@ public void run() {
* Will be retried on the next loop, and
* break if the callback scheduler is closed.
*/
if (LOG.isDebugEnabled()) {
LOG.debug("wait on empty callback queue interrupted: " + e.getMessage());
}
LOG.debug("wait on empty callback queue interrupted: {}", e.getMessage());
}
continue;
}
Expand All @@ -124,9 +122,7 @@ public void run() {
// this takes care of start and stop
session.startingCallback(messageConsumer);
} catch (JMSException e) {
if (LOG.isDebugEnabled()) {
LOG.debug("Not running callback: " + e.getMessage());
}
LOG.debug("Not running callback: {}", e.getMessage());
break;
}

Expand All @@ -147,8 +143,8 @@ public void run() {
try {
messageListener.onMessage(message);
} catch (Throwable ex) {
LOG.info("Exception thrown from onMessage callback for message " +
message.getSQSMessageId(), ex);
LOG.warn("Exception thrown from onMessage callback for message {}",
message.getSQSMessageId(), ex);
callbackFailed = true;
} finally {
if (!callbackFailed) {
Expand All @@ -160,9 +156,8 @@ public void run() {
}
}
} catch (JMSException ex) {
LOG.warn(
"Unable to complete message dispatch for the message " +
message.getSQSMessageId(), ex);
LOG.warn("Unable to complete message dispatch for the message {}",
message.getSQSMessageId(), ex);
} finally {
if (tryNack) {
nackReceivedMessage(message);
Expand Down Expand Up @@ -248,7 +243,7 @@ private void nackReceivedMessage(SQSMessage message) {

negativeAcknowledger.bulkAction(nackMessageIdentifiers, nackMessageIdentifiers.size());
} catch (JMSException e) {
LOG.warn("Unable to nack the message " + message.getSQSMessageId(), e);
LOG.warn("Unable to nack the message {}", message.getSQSMessageId(), e);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,8 @@ public void acknowledge(SQSMessage message) throws JMSException {
* the messages received before that
*/
if (indexOfMessage == -1) {
LOG.warn("SQSMessageID: " + message.getSQSMessageId() + " with SQSMessageReceiptHandle: " +
message.getReceiptHandle() + " does not exist.");
LOG.warn("SQSMessageID: {} with SQSMessageReceiptHandle: {} does not exist.", message.getSQSMessageId(),
message.getReceiptHandle());
} else {
bulkAction(getUnAckMessages(), indexOfMessage);
}
Expand Down