refactoring #1012: Format specifiers should be used instead of string concatenation. (#2715)

* refactoring #1012: Format specifiers should be used instead of string concatenation.

* refactoring #1012: Format specifiers should be used instead of string concatenation.

* refactoring #1012: Remove isInfoEnabled check
This commit is contained in:
kongleong86
2023-12-02 12:25:00 +00:00
committed by GitHub
parent a82966f202
commit 301317533e
9 changed files with 19 additions and 19 deletions
@@ -477,8 +477,8 @@ public class Commander {
&& System.currentTimeMillis() - o.createdTime < messageTime) {
var qt = new QueueTask(order, TaskType.MESSAGING, 1);
updateQueue(qt);
LOG.warn("Order " + order.id + ": Error in sending Payment Error message, "
+ "trying to queue task and add to employee handle..");
LOG.warn("Order {}: Error in sending Payment Error message, trying to queue task and add to employee handle..",
order.id);
employeeHandleIssue(o);
}
}
+1 -1
View File
@@ -62,7 +62,7 @@ public class App {
final var logger = LoggerFactory.getLogger(App.class);
var name = unit.getName();
Function<String, Runnable> func = (e) -> () -> logger.info(name + " without " + e);
Function<String, Runnable> func = e -> () -> logger.info("{} without {}", name, e);
var extension = "SoldierExtension";
Optional.ofNullable(unit.getUnitExtension(extension))
@@ -39,12 +39,10 @@ public abstract class GameLoop {
protected final GameController controller;
private Thread gameThread;
/**
* Initialize game status to be stopped.
*/
public GameLoop() {
protected GameLoop() {
controller = new GameController();
status = GameStatus.STOPPED;
}
@@ -54,7 +52,7 @@ public abstract class GameLoop {
*/
public void run() {
status = GameStatus.RUNNING;
gameThread = new Thread(this::processGameLoop);
Thread gameThread = new Thread(this::processGameLoop);
gameThread.start();
}
@@ -85,6 +83,8 @@ public abstract class GameLoop {
Thread.sleep(lag);
} catch (InterruptedException e) {
logger.error(e.getMessage());
/* Clean up whatever needs to be handled before interrupting */
Thread.currentThread().interrupt();
}
}
@@ -94,7 +94,7 @@ public abstract class GameLoop {
*/
protected void render() {
var position = controller.getBulletPosition();
logger.info("Current bullet position: " + position);
logger.info("Current bullet position: {}", position);
}
/**
@@ -42,6 +42,6 @@ public class InvalidUser implements ReceiptViewModel {
@Override
public void show() {
LOGGER.info("Invalid user: " + userName);
LOGGER.info(String.format("Invalid user: %s", userName));
}
}
@@ -55,6 +55,6 @@ public class MaintenanceLock {
public void setLock(boolean lock) {
this.lock = lock;
LOGGER.info("Maintenance lock is set to: ", lock);
LOGGER.info("Maintenance lock is set to: {}", lock);
}
}
@@ -34,8 +34,8 @@ public class OutOfStock implements ReceiptViewModel {
private static final Logger LOGGER = LoggerFactory.getLogger(OutOfStock.class);
private String userName;
private String itemName;
private final String userName;
private final String itemName;
public OutOfStock(String userName, String itemName) {
this.userName = userName;
@@ -44,6 +44,6 @@ public class OutOfStock implements ReceiptViewModel {
@Override
public void show() {
LOGGER.info("Out of stock: " + itemName + " for user = " + userName + " to buy");
LOGGER.info(String.format("Out of stock: %s for user = %s to buy", itemName, userName));
}
}
@@ -34,7 +34,7 @@ public class ReceiptDto implements ReceiptViewModel {
private static final Logger LOGGER = LoggerFactory.getLogger(ReceiptDto.class);
private Double price;
private final Double price;
public ReceiptDto(Double price) {
this.price = price;
@@ -46,6 +46,6 @@ public class ReceiptDto implements ReceiptViewModel {
@Override
public void show() {
LOGGER.info("Receipt: " + price + " paid");
LOGGER.info(String.format("Receipt: %s paid", price));
}
}
@@ -47,7 +47,7 @@ public abstract class Superpower {
* @param z Z coordinate.
*/
protected void move(double x, double y, double z) {
logger.info("Move to ( " + x + ", " + y + ", " + z + " )");
logger.info("Move to ( {}, {}, {} )", x, y, z);
}
/**
@@ -56,7 +56,7 @@ public abstract class Superpower {
* @param volume Value of volume.
*/
protected void playSound(String soundName, int volume) {
logger.info("Play " + soundName + " with volume " + volume);
logger.info("Play {} with volume {}", soundName, volume);
}
/**
@@ -65,6 +65,6 @@ public abstract class Superpower {
* @param count Count of particles to be spawned.
*/
protected void spawnParticles(String particleType, int count) {
logger.info("Spawn " + count + " particle with type " + particleType);
logger.info("Spawn {} particle with type {}", count, particleType);
}
}
@@ -65,6 +65,6 @@ public class Statue extends Entity {
}
private void shootLightning() {
logger.info("Statue " + id + " shoots lightning!");
logger.info("Statue {} shoots lightning!", id);
}
}