Skip to content

Commit 18ef269

Browse files
committed
Simplify code by removing usage of String.format() for log messages.
From http://www.baeldung.com/slf4j-log-exceptions % In presence of multiple parameters, if the last argument in a logging statement is an exception, then SLF4J will presume that the user wants the last argument to be treated as an exception instead of a simple parameter. % No functional changes.
1 parent 1fa959a commit 18ef269

File tree

2 files changed

+5
-8
lines changed

2 files changed

+5
-8
lines changed

src/main/java/ru/mystamps/web/controller/ErrorController.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -67,12 +67,12 @@ public void internalError(
6767
// TODO: log to database (with *.status_code, *.message, *.servlet_name and user details)
6868

6969
if (page != null && !Url.INTERNAL_ERROR_PAGE.equals(page)) {
70-
String msg = String.format(
71-
"Exception '%s' occurred at page %s",
70+
LOG.error(
71+
"Exception '{}' occurred on page {}",
7272
getNameOrAsIs(exceptionType),
73-
page
73+
page,
74+
exception
7475
);
75-
LOG.error(msg, exception);
7676
}
7777
}
7878

src/main/java/ru/mystamps/web/service/ImageServiceImpl.java

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -166,10 +166,7 @@ private ImageDto createPreview(ImageInfoDto previewInfo, byte[] image) {
166166
return new DbImageDto("jpeg", preview);
167167

168168
} catch (CreateImagePreviewException | ImagePersistenceException ex) {
169-
log.warn(
170-
String.format("Image #%d: couldn't create/save preview", previewInfo.getId()),
171-
ex
172-
);
169+
log.warn("Image #{}: couldn't create/save preview", previewInfo.getId(), ex);
173170
return null;
174171
}
175172
}

0 commit comments

Comments
 (0)