Skip to content

Commit 17ddf9f

Browse files
Jiankai ZhengJiankai Zheng
authored andcommitted
refactor(logging): use slfj4 internal string format
1 parent 8920dc3 commit 17ddf9f

21 files changed

+99
-101
lines changed

src/main/java/spotify/api/authorization/AuthorizationCodeFlow.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ public String constructUrl() {
4747
"&show_dialog=" + showDialog;
4848

4949
logger.trace("Constructing url for authorization code flow");
50-
logger.debug(String.format("Constructed url: %s.", constructedUrl));
50+
logger.debug("Constructed url: {}.", constructedUrl);
5151
return constructedUrl;
5252
}
5353

src/main/java/spotify/api/authorization/AuthorizationCodeFlowPKCE.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ public String constructUrl() {
4949
"&code_challenge=" + codeChallenge;
5050

5151
logger.trace("Constructing url for authorization PKCE code flow");
52-
logger.debug(String.format("Constructed url: %s.", constructedUrl));
52+
logger.debug("Constructed url: {}.", constructedUrl);
5353
return constructedUrl;
5454
}
5555

src/main/java/spotify/api/impl/AlbumApiRetrofit.java

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ public AlbumFull getAlbum(String albumId, Map<String, String> options) {
4040

4141
try {
4242
logger.info("Executing HTTP call to fetch an album.");
43-
logger.debug(String.format("Fetching album %s with following values: %s.", albumId, options));
43+
logger.debug("Fetching album {} with following values: {}.", albumId, options);
4444
LoggingUtil.logHttpCall(logger, httpCall);
4545
Response<AlbumFull> response = httpCall.execute();
4646

@@ -60,14 +60,14 @@ public AlbumFullCollection getAlbums(List<String> listOfAlbumIds, Map<String, St
6060
options = ValidatorUtil.optionsValueCheck(options);
6161

6262
String albumIds = String.join(",", listOfAlbumIds);
63-
logger.debug(String.format("Mapped list of album ids to String: %s", albumIds));
63+
logger.debug("Mapped list of album ids to String: {}", albumIds);
6464

6565
logger.trace("Constructing HTTP call to fetch albums.");
6666
Call<AlbumFullCollection> httpCall = albumService.getAlbums("Bearer " + this.accessToken, albumIds, options);
6767

6868
try {
6969
logger.info("Executing HTTP call to fetch albums.");
70-
logger.debug(String.format("Fetching following albums: %s with following values: %s.", albumIds, options));
70+
logger.debug("Fetching following albums: {} with following values: {}.", albumIds, options);
7171
LoggingUtil.logHttpCall(logger, httpCall);
7272
Response<AlbumFullCollection> response = httpCall.execute();
7373

@@ -90,7 +90,7 @@ public Paging<TrackSimplified> getAlbumTracks(String albumId, Map<String, String
9090

9191
try {
9292
logger.info("Executing HTTP call to fetch album tracks.");
93-
logger.debug(String.format("Fetching album %s tracks with following values: %s.", albumId, options));
93+
logger.debug("Fetching album {} tracks with following values: {}.", albumId, options);
9494
LoggingUtil.logHttpCall(logger, httpCall);
9595
Response<Paging<TrackSimplified>> response = httpCall.execute();
9696

@@ -103,6 +103,7 @@ public Paging<TrackSimplified> getAlbumTracks(String albumId, Map<String, String
103103
throw new HttpRequestFailedException(ex.getMessage());
104104
}
105105
}
106+
106107
private void validateAlbumListSizeAndThrowIfExceeded(List<String> listOfAlbumIds, int maximumAmountOfAlbumIdsAllowed) {
107108
final int listSize = listOfAlbumIds.size();
108109

src/main/java/spotify/api/impl/ArtistApiRetrofit.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ public Paging<ArtistSimplified> getArtistAlbums(String artistId, List<AlbumType>
7171

7272
try {
7373
logger.info("Executing HTTP call to fetch albums of artist.");
74-
logger.debug(String.format("Fetching artist %s albums with following values: %s.", artistId, options));
74+
logger.debug("Fetching artist {} albums with following values: {}.", artistId, options);
7575
LoggingUtil.logHttpCall(logger, httpCall);
7676
Response<Paging<ArtistSimplified>> response = httpCall.execute();
7777

@@ -94,7 +94,7 @@ public TrackFullCollection getArtistTopTracks(String artistId, Map<String, Strin
9494

9595
try {
9696
logger.info("Executing HTTP call to fetch an artist top tracks.");
97-
logger.debug(String.format("Fetching artist %s top tracks with following values: %s.", artistId, options));
97+
logger.debug("Fetching artist {} top tracks with following values: {}.", artistId, options);
9898
LoggingUtil.logHttpCall(logger, httpCall);
9999
Response<TrackFullCollection> response = httpCall.execute();
100100

src/main/java/spotify/api/impl/BrowseApiRetrofit.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ public CategoryFull getCategory(String categoryId, Map<String, String> options)
4242

4343
try {
4444
logger.info("Executing HTTP call to fetch category.");
45-
logger.debug(String.format("Fetching category %s with following values: %s.", categoryId, options));
45+
logger.debug("Fetching category {} with following values: {}.", categoryId, options);
4646
LoggingUtil.logHttpCall(logger, httpCall);
4747
Response<CategoryFull> response = httpCall.execute();
4848

@@ -65,7 +65,7 @@ public PlaylistSimplifiedPaging getCategoryPlaylists(String categoryId, Map<Stri
6565

6666
try {
6767
logger.info("Executing HTTP call to fetch category playlists.");
68-
logger.debug(String.format("Fetching category %s playlists with following values: %s.", categoryId, options));
68+
logger.debug("Fetching category {} playlists with following values: {}.", categoryId, options);
6969
LoggingUtil.logHttpCall(logger, httpCall);
7070
Response<PlaylistSimplifiedPaging> response = httpCall.execute();
7171

@@ -88,7 +88,7 @@ public CategoryFullPaging getCategories(Map<String, String> options) {
8888

8989
try {
9090
logger.info("Executing HTTP call to fetch categories.");
91-
logger.debug(String.format("Fetching categories with following values: %s.", options));
91+
logger.debug("Fetching categories with following values: {}.", options);
9292
LoggingUtil.logHttpCall(logger, httpCall);
9393
Response<CategoryFullPaging> response = httpCall.execute();
9494

@@ -111,7 +111,7 @@ public FeaturedPlaylistCollection getFeaturedPlaylists(Map<String, String> optio
111111

112112
try {
113113
logger.info("Executing HTTP call to fetch featured playlists.");
114-
logger.debug(String.format("Fetching featured playlists with following values: %s", options));
114+
logger.debug("Fetching featured playlists with following values: {}", options);
115115
LoggingUtil.logHttpCall(logger, httpCall);
116116
Response<FeaturedPlaylistCollection> response = httpCall.execute();
117117

@@ -134,7 +134,7 @@ public AlbumSimplifiedPaging getNewReleases(Map<String, String> options) {
134134

135135
try {
136136
logger.info("Executing HTTP call to fetch new releases.");
137-
logger.debug(String.format("Fetching new releases with following values: %s", options));
137+
logger.debug("Fetching new releases with following values: {}", options);
138138
LoggingUtil.logHttpCall(logger, httpCall);
139139
Response<AlbumSimplifiedPaging> response = httpCall.execute();
140140

@@ -159,7 +159,7 @@ public RecommendationCollection getRecommendations(List<String> listOfSeedArtist
159159

160160
try {
161161
logger.info("Executing HTTP call to fetch recommendations.");
162-
logger.debug(String.format("Fetching recommendations with following values: %s", options));
162+
logger.debug("Fetching recommendations with following values: {}", options);
163163
LoggingUtil.logHttpCall(logger, httpCall);
164164
Response<RecommendationCollection> response = httpCall.execute();
165165

src/main/java/spotify/api/impl/EpisodeApiRetrofit.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ public EpisodeFull getEpisode(String episodeId, Map<String, String> options) {
3838

3939
try {
4040
logger.info("Executing HTTP call to fetch episode.");
41-
logger.debug(String.format("Fetching episodes %s with following values: %s.", episodeId, options));
41+
logger.debug("Fetching episodes {} with following values: {}.", episodeId, options);
4242
LoggingUtil.logHttpCall(logger, httpCall);
4343
Response<EpisodeFull> response = httpCall.execute();
4444

@@ -64,7 +64,7 @@ public EpisodeFullCollection getEpisodes(List<String> listOfEpisodeIds, Map<Stri
6464

6565
try {
6666
logger.info("Executing HTTP call to fetch multiple episodes.");
67-
logger.debug(String.format("Fetching following episodes: %s with following values: %s.", episodeIds, options));
67+
logger.debug("Fetching following episodes: {} with following values: {}.", episodeIds, options);
6868
LoggingUtil.logHttpCall(logger, httpCall);
6969
Response<EpisodeFullCollection> response = httpCall.execute();
7070

src/main/java/spotify/api/impl/FollowApiRetrofit.java

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ public List<Boolean> isFollowing(EntityType entityType, List<String> listOfEntit
4141

4242
try {
4343
logger.info("Executing HTTP call to check if user follows the provided entities.");
44-
logger.debug(String.format("Fetching %s following list with following entity ids: %s.", entityType, entityIds));
44+
logger.debug("Fetching {} following list with following entity ids: {}.", entityType, entityIds);
4545
LoggingUtil.logHttpCall(logger, httpCall);
4646
Response<List<Boolean>> response = httpCall.execute();
4747

@@ -64,7 +64,7 @@ public List<Boolean> isFollowingPlaylist(String playlistId, List<String> listOfU
6464

6565
try {
6666
logger.info("Executing HTTP call to check if users are following the playlist.");
67-
logger.debug(String.format("Fetching %s playlist following list with following user ids: %s.", playlistId, userIds));
67+
logger.debug("Fetching {} playlist following list with following user ids: {}.", playlistId, userIds);
6868
LoggingUtil.logHttpCall(logger, httpCall);
6969
Response<List<Boolean>> response = httpCall.execute();
7070

@@ -87,7 +87,7 @@ public void followEntities(EntityType entityType, List<String> listOfEntityIds)
8787

8888
try {
8989
logger.info("Executing HTTP call to follow entities.");
90-
logger.debug(String.format("Following entities with following entity ids: %s.", entityIds));
90+
logger.debug("Following entities with following entity ids: {}.", entityIds);
9191
LoggingUtil.logHttpCall(logger, httpCall);
9292
Response<Void> response = httpCall.execute();
9393

@@ -107,7 +107,7 @@ public void followPlaylist(String playlistId, boolean setPlaylistPublic) {
107107

108108
try {
109109
logger.info("Executing HTTP call to follow playlist.");
110-
logger.debug(String.format("Following playlist %s and set it to %s", playlistId, setPlaylistPublic ? "public" : "private"));
110+
logger.debug("Following playlist {} and set it to {}", playlistId, setPlaylistPublic ? "public" : "private");
111111
LoggingUtil.logHttpCall(logger, httpCall);
112112
Response<Void> response = httpCall.execute();
113113

@@ -127,7 +127,7 @@ public CursorBasedPaging<ArtistFull> getFollowedArtists(EntityType entityType, M
127127

128128
try {
129129
logger.info("Executing HTTP call to fetch followed artists of the current user.");
130-
logger.debug(String.format("Fetching current user's followed artists with the following values: %s", options));
130+
logger.debug("Fetching current user's followed artists with the following values: {}", options);
131131
LoggingUtil.logHttpCall(logger, httpCall);
132132
Response<ArtistFullCursorBasedPagingWrapper> response = httpCall.execute();
133133

@@ -157,7 +157,7 @@ public void unfollowEntities(EntityType entityType, List<String> listOfEntityIds
157157

158158
try {
159159
logger.info("Executing HTTP call to unfollow entities.");
160-
logger.debug(String.format("Unfollowing entities with following entity ids: %s.", entityIds));
160+
logger.debug("Unfollowing entities with following entity ids: {}.", entityIds);
161161
LoggingUtil.logHttpCall(logger, httpCall);
162162
Response<Void> response = httpCall.execute();
163163

@@ -177,7 +177,7 @@ public void unfollowPlaylist(String playlistId) {
177177

178178
try {
179179
logger.info("Executing HTTP call to unfollow playlist.");
180-
logger.debug(String.format("Unfollowing playlist %s ", playlistId));
180+
logger.debug("Unfollowing playlist {} ", playlistId);
181181
LoggingUtil.logHttpCall(logger, httpCall);
182182
Response<Void> response = httpCall.execute();
183183

src/main/java/spotify/api/impl/LibraryApiRetrofit.java

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ public List<Boolean> hasSavedAlbums(List<String> listOfAlbumIds) {
4040

4141
try {
4242
logger.info("Executing HTTP call to check saved albums.");
43-
logger.debug(String.format("Checking albums with following album ids: %s.", albumIds));
43+
logger.debug("Checking albums with following album ids: {}.", albumIds);
4444
LoggingUtil.logHttpCall(logger, httpCall);
4545
Response<List<Boolean>> response = httpCall.execute();
4646

@@ -63,7 +63,7 @@ public List<Boolean> hasSavedShows(List<String> listOfShowIds) {
6363

6464
try {
6565
logger.info("Executing HTTP call to check saved shows.");
66-
logger.debug(String.format("Checking shows with following show ids: %s.", showIds));
66+
logger.debug("Checking shows with following show ids: {}.", showIds);
6767
LoggingUtil.logHttpCall(logger, httpCall);
6868
Response<List<Boolean>> response = httpCall.execute();
6969

@@ -86,7 +86,7 @@ public List<Boolean> hasSavedTracks(List<String> listOfTrackIds) {
8686

8787
try {
8888
logger.info("Executing HTTP call to check saved tracks.");
89-
logger.debug(String.format("Checking tracks with following track ids: %s.", trackIds));
89+
logger.debug("Checking tracks with following track ids: {}.", trackIds);
9090
LoggingUtil.logHttpCall(logger, httpCall);
9191
Response<List<Boolean>> response = httpCall.execute();
9292

@@ -109,7 +109,7 @@ public Paging<SavedAlbumFull> getSavedAlbums(Map<String, String> options) {
109109

110110
try {
111111
logger.info("Executing HTTP call to fetch current user saved albums");
112-
logger.debug(String.format("Fetching current user saved albums with the following values: %s.", options));
112+
logger.debug("Fetching current user saved albums with the following values: {}.", options);
113113
LoggingUtil.logHttpCall(logger, httpCall);
114114
Response<Paging<SavedAlbumFull>> response = httpCall.execute();
115115

@@ -132,7 +132,7 @@ public Paging<SavedShowSimplified> getSavedShows(Map<String, String> options) {
132132

133133
try {
134134
logger.info("Executing HTTP call to fetch current user saved shows");
135-
logger.debug(String.format("Fetching current user saved shows with the following values: %s.", options));
135+
logger.debug("Fetching current user saved shows with the following values: {}.", options);
136136
LoggingUtil.logHttpCall(logger, httpCall);
137137
Response<Paging<SavedShowSimplified>> response = httpCall.execute();
138138

@@ -155,7 +155,7 @@ public Paging<SavedTrackFull> getSavedTracks(Map<String, String> options) {
155155

156156
try {
157157
logger.info("Executing HTTP call to fetch current user saved tracks");
158-
logger.debug(String.format("Fetching current user saved tracks with the following values: %s.", options));
158+
logger.debug("Fetching current user saved tracks with the following values: {}.", options);
159159
LoggingUtil.logHttpCall(logger, httpCall);
160160
Response<Paging<SavedTrackFull>> response = httpCall.execute();
161161

@@ -179,7 +179,7 @@ public void saveAlbums(List<String> listOfAlbumIds) {
179179

180180
try {
181181
logger.info("Executing HTTP call to save the given albums.");
182-
logger.debug(String.format("Saving albums with following album ids: %s.", albumIds));
182+
logger.debug("Saving albums with following album ids: {}.", albumIds);
183183
LoggingUtil.logHttpCall(logger, httpCall);
184184
Response<Void> response = httpCall.execute();
185185

@@ -201,7 +201,7 @@ public void saveShows(List<String> listOfShowIds) {
201201

202202
try {
203203
logger.info("Executing HTTP call to save the given shows.");
204-
logger.debug(String.format("Saving shows with following show ids: %s.", showIds));
204+
logger.debug("Saving shows with following show ids: {}.", showIds);
205205
LoggingUtil.logHttpCall(logger, httpCall);
206206
Response<Void> response = httpCall.execute();
207207

@@ -223,7 +223,7 @@ public void saveTracks(List<String> listOfTrackIds) {
223223

224224
try {
225225
logger.info("Executing HTTP call to save the given tracks.");
226-
logger.debug(String.format("Saving tracks with following track ids: %s.", trackIds));
226+
logger.debug("Saving tracks with following track ids: {}.", trackIds);
227227
LoggingUtil.logHttpCall(logger, httpCall);
228228
Response<Void> response = httpCall.execute();
229229

@@ -245,7 +245,7 @@ public void deleteAlbums(List<String> listOfAlbumIds) {
245245

246246
try {
247247
logger.info("Executing HTTP call to delete the saved albums.");
248-
logger.debug(String.format("Deleting saved albums with following album ids: %s.", albumIds));
248+
logger.debug("Deleting saved albums with following album ids: {}.", albumIds);
249249
LoggingUtil.logHttpCall(logger, httpCall);
250250
Response<Void> response = httpCall.execute();
251251

@@ -269,7 +269,7 @@ public void deleteShows(List<String> listOfShowIds, Map<String, String> options)
269269

270270
try {
271271
logger.info("Executing HTTP call to delete the saved shows.");
272-
logger.debug(String.format("Deleting saved shows with following show ids: %s and parameter values: %s.", showIds, options));
272+
logger.debug("Deleting saved shows with following show ids: {} and parameter values: {}.", showIds, options);
273273
LoggingUtil.logHttpCall(logger, httpCall);
274274
Response<Void> response = httpCall.execute();
275275

@@ -291,7 +291,7 @@ public void deleteTracks(List<String> listOfTrackIds) {
291291

292292
try {
293293
logger.info("Executing HTTP call to delete the saved tracks.");
294-
logger.debug(String.format("Deleting saved tracks with following track ids: %s.", trackIds));
294+
logger.debug("Deleting saved tracks with following track ids: {}.", trackIds);
295295
LoggingUtil.logHttpCall(logger, httpCall);
296296
Response<Void> response = httpCall.execute();
297297

src/main/java/spotify/api/impl/PersonalizationApiRetrofit.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ public Paging<ArtistFull> getTopArtists(Map<String, String> options) {
3838

3939
try {
4040
logger.info("Executing HTTP call to fetch top artists.");
41-
logger.debug(String.format("Fetching top artists with following values: %s.", options));
41+
logger.debug("Fetching top artists with following values: {}.", options);
4242
LoggingUtil.logHttpCall(logger, httpCall);
4343
Response<Paging<ArtistFull>> response = httpCall.execute();
4444

@@ -61,7 +61,7 @@ public Paging<TrackFull> getTopTracks(Map<String, String> options) {
6161

6262
try {
6363
logger.info("Executing HTTP call to fetch top tracks.");
64-
logger.debug(String.format("Fetching top tracks with following values: %s.", options));
64+
logger.debug("Fetching top tracks with following values: {}.", options);
6565
LoggingUtil.logHttpCall(logger, httpCall);
6666
Response<Paging<TrackFull>> response = httpCall.execute();
6767

0 commit comments

Comments
 (0)