Fix incorrect usage or log.XXX methods - replace String.format with log.XXX formatter

This commit is contained in:
Volodymyr Babak 2022-11-01 15:58:13 +02:00
parent 4a2e40fdb5
commit a2b404788b
4 changed files with 5 additions and 10 deletions

View File

@ -205,8 +205,7 @@ class DeviceActorMessageProcessor extends AbstractContextAwareMsgProcessor {
saveRpcRequestToEdgeQueue(request, rpcRequest.getRequestId()).get(); saveRpcRequestToEdgeQueue(request, rpcRequest.getRequestId()).get();
sent = true; sent = true;
} catch (InterruptedException | ExecutionException e) { } catch (InterruptedException | ExecutionException e) {
String errMsg = String.format("[%s][%s][%s] Failed to save rpc request to edge queue %s", tenantId, deviceId, edgeId.getId(), request); log.error("[{}][{}][{}] Failed to save rpc request to edge queue {}", tenantId, deviceId, edgeId.getId(), request, e);
log.error(errMsg, e);
} }
} else if (isSendNewRpcAvailable()) { } else if (isSendNewRpcAvailable()) {
sent = rpcSubscriptions.size() > 0; sent = rpcSubscriptions.size() > 0;

View File

@ -240,8 +240,7 @@ public class DefaultEdgeNotificationService implements EdgeNotificationService {
} }
private void callBackFailure(TransportProtos.EdgeNotificationMsgProto edgeNotificationMsg, TbCallback callback, Throwable throwable) { private void callBackFailure(TransportProtos.EdgeNotificationMsgProto edgeNotificationMsg, TbCallback callback, Throwable throwable) {
String errMsg = String.format("Can't push to edge updates, edgeNotificationMsg [%s]", edgeNotificationMsg); log.error("Can't push to edge updates, edgeNotificationMsg [{}]", edgeNotificationMsg, throwable);
log.error(errMsg, throwable);
callback.onFailure(throwable); callback.onFailure(throwable);
} }

View File

@ -625,8 +625,7 @@ public final class EdgeGrpcSession implements Closeable {
} }
} }
} catch (Exception e) { } catch (Exception e) {
String errMsg = String.format("[%s] Can't process uplink msg [%s]", this.sessionId, uplinkMsg); log.error("[{}] Can't process uplink msg [{}]", this.sessionId, uplinkMsg, e);
log.error(errMsg, e);
return Futures.immediateFailedFuture(e); return Futures.immediateFailedFuture(e);
} }
return Futures.allAsList(result); return Futures.allAsList(result);

View File

@ -100,8 +100,7 @@ public class DeviceEdgeProcessor extends BaseEdgeProcessor {
try { try {
newDevice = createDevice(tenantId, edge, deviceUpdateMsg, newDeviceName); newDevice = createDevice(tenantId, edge, deviceUpdateMsg, newDeviceName);
} catch (DataValidationException e) { } catch (DataValidationException e) {
String errMsg = String.format("[%s] Device update msg can't be processed due to data validation [%s]", tenantId, deviceUpdateMsg); log.error("[{}] Device update msg can't be processed due to data validation [{}]", tenantId, deviceUpdateMsg, e);
log.error(errMsg, e);
return Futures.immediateFuture(null); return Futures.immediateFuture(null);
} }
ObjectNode body = JacksonUtil.OBJECT_MAPPER.createObjectNode(); ObjectNode body = JacksonUtil.OBJECT_MAPPER.createObjectNode();
@ -116,8 +115,7 @@ public class DeviceEdgeProcessor extends BaseEdgeProcessor {
try { try {
device = createDevice(tenantId, edge, deviceUpdateMsg, deviceUpdateMsg.getName()); device = createDevice(tenantId, edge, deviceUpdateMsg, deviceUpdateMsg.getName());
} catch (DataValidationException e) { } catch (DataValidationException e) {
String errMsg = String.format("[%s] Device update msg can't be processed due to data validation [%s]", tenantId, deviceUpdateMsg); log.error("[{}] Device update msg can't be processed due to data validation [{}]", tenantId, deviceUpdateMsg, e);
log.error(errMsg, e);
return Futures.immediateFuture(null); return Futures.immediateFuture(null);
} }
return saveEdgeEvent(tenantId, edge.getId(), EdgeEventType.DEVICE, EdgeEventActionType.CREDENTIALS_REQUEST, device.getId(), null); return saveEdgeEvent(tenantId, edge.getId(), EdgeEventType.DEVICE, EdgeEventActionType.CREDENTIALS_REQUEST, device.getId(), null);