logging: use format specifiers instead of string concatenation

This commit is contained in:
Petr Široký
2023-03-10 21:34:21 +01:00
committed by Guillaume Nodet
parent b0b7115344
commit 50653ae7d9
6 changed files with 35 additions and 30 deletions

View File

@@ -389,7 +389,7 @@ public class Server implements AutoCloseable, Runnable {
private void requestStop(String reason) {
DaemonState state = getState();
if (!(state == StopRequested || state == Stopped)) {
LOGGER.info("Daemon will be stopped at the end of the build " + reason);
LOGGER.info("Daemon will be stopped at the end of the build {}", reason);
stateLock.lock();
try {
if (state == Busy) {
@@ -405,7 +405,7 @@ public class Server implements AutoCloseable, Runnable {
}
private void requestForcefulStop(String reason) {
LOGGER.info("Daemon is stopping immediately " + reason);
LOGGER.info("Daemon is stopping immediately {}", reason);
stopNow(reason);
}
@@ -533,7 +533,7 @@ public class Server implements AutoCloseable, Runnable {
LOGGER.info("No more message to dispatch");
return;
}
LOGGER.info("Dispatch message: " + m);
LOGGER.info("Dispatch message: {}", m);
connection.dispatch(m);
}
} catch (Throwable t) {
@@ -637,7 +637,7 @@ public class Server implements AutoCloseable, Runnable {
private void updateState(DaemonState state) {
if (getState() != state) {
LOGGER.info("Updating state to: " + state);
LOGGER.info("Updating state to: {}", state);
stateLock.lock();
try {
registry.store(info = info.withState(state));

View File

@@ -154,7 +154,7 @@ public class DaemonPrompter extends AbstractInputHandler implements Prompter, In
Connection con = Objects.requireNonNull(Connection.getCurrent());
String projectId = ProjectBuildLogAppender.getProjectId();
Message.ProjectEvent msg = Message.display(projectId, message);
LOGGER.info("Sending display request: " + msg);
LOGGER.info("Sending display request: {}", msg);
con.dispatch(msg);
} catch (Exception e) {
throw new IOException("Unable to display message", e);
@@ -167,9 +167,9 @@ public class DaemonPrompter extends AbstractInputHandler implements Prompter, In
String projectId = ProjectBuildLogAppender.getProjectId();
String uid = UUID.randomUUID().toString();
Message.Prompt msg = new Message.Prompt(projectId, uid, message, password);
LOGGER.info("Requesting prompt: " + msg);
LOGGER.info("Requesting prompt: {}", msg);
Message.PromptResponse res = con.request(msg, Message.PromptResponse.class, r -> uid.equals(r.getUid()));
LOGGER.info("Received response: " + res.getMessage());
LOGGER.info("Received response: {}", res.getMessage());
return res.getMessage();
} catch (Exception e) {
throw new IOException("Unable to prompt user", e);