Skip to content

Commit 489a4fd

Browse files
committed
Minor logging changes + minor FileConfiguration clean up
1 parent 29e6dac commit 489a4fd

4 files changed

Lines changed: 55 additions & 28 deletions

File tree

api/pom.xml

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -73,16 +73,20 @@
7373
</dependency>
7474

7575
<!-- Logging -->
76+
<dependency>
77+
<groupId>org.apache.logging.log4j</groupId>
78+
<artifactId>log4j-api</artifactId>
79+
<version>${log4j.version}</version>
80+
</dependency>
7681
<dependency>
7782
<groupId>org.apache.logging.log4j</groupId>
7883
<artifactId>log4j-core</artifactId>
79-
<version>${log4j-core.version}</version>
84+
<version>${log4j.version}</version>
8085
</dependency>
8186
<dependency>
8287
<groupId>org.apache.logging.log4j</groupId>
8388
<artifactId>log4j-slf4j-impl</artifactId>
84-
<version>${log4j-slf4j-impl.version}</version>
85-
<scope>runtime</scope>
89+
<version>${log4j.version}</version>
8690
</dependency>
8791
<dependency>
8892
<groupId>com.lmax</groupId>

player/pom.xml

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -113,28 +113,32 @@
113113
</dependency>
114114

115115
<!-- Logging -->
116+
<dependency>
117+
<groupId>org.slf4j</groupId>
118+
<artifactId>slf4j-api</artifactId>
119+
<version>${slf4j-api.version}</version>
120+
</dependency>
121+
<dependency>
122+
<groupId>org.apache.logging.log4j</groupId>
123+
<artifactId>log4j-api</artifactId>
124+
<version>${log4j.version}</version>
125+
</dependency>
116126
<dependency>
117127
<groupId>org.apache.logging.log4j</groupId>
118128
<artifactId>log4j-core</artifactId>
119-
<version>${log4j-core.version}</version>
129+
<version>${log4j.version}</version>
120130
</dependency>
121131
<dependency>
122132
<groupId>org.apache.logging.log4j</groupId>
123133
<artifactId>log4j-slf4j-impl</artifactId>
124-
<version>${log4j-slf4j-impl.version}</version>
125-
<scope>runtime</scope>
134+
<version>${log4j.version}</version>
126135
</dependency>
127136
<dependency>
128137
<groupId>com.lmax</groupId>
129138
<artifactId>disruptor</artifactId>
130139
<version>${lmax-disruptor.version}</version>
131140
<scope>runtime</scope>
132141
</dependency>
133-
<dependency>
134-
<groupId>org.slf4j</groupId>
135-
<artifactId>slf4j-api</artifactId>
136-
<version>${slf4j-api.version}</version>
137-
</dependency>
138142

139143
<!-- TOML configuration -->
140144
<dependency>

player/src/main/java/xyz/gianlu/librespot/player/FileConfiguration.java

Lines changed: 35 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -209,14 +209,21 @@ private void updateConfigFile(@NotNull CommentedConfig defaultConfig) {
209209
}
210210
}
211211

212+
@Nullable
213+
private File getFile(@NotNull String key) {
214+
String path = config.get(key);
215+
return path == null ? null : new File(path);
216+
}
217+
212218
@NotNull
213219
private String[] getStringArray(@NotNull String key, char separator) {
214220
String str = config.get(key);
215221
if ((str = str.trim()).isEmpty()) return new String[0];
216222
else return Utils.split(str, separator);
217223
}
218224

219-
private @NotNull AudioQuality preferredQuality() {
225+
@NotNull
226+
private AudioQuality preferredQuality() {
220227
try {
221228
return config.getEnum("player.preferredAudioQuality", AudioQuality.class);
222229
} catch (IllegalArgumentException ex) { // Retro-compatibility
@@ -236,13 +243,15 @@ private String[] getStringArray(@NotNull String key, char separator) {
236243
}
237244
}
238245

239-
private @Nullable File outputPipe() {
246+
@Nullable
247+
private File outputPipe() {
240248
String path = config.get("player.pipe");
241249
if (path == null || path.isEmpty()) return null;
242250
return new File(path);
243251
}
244252

245-
private @Nullable File metadataPipe() {
253+
@Nullable
254+
private File metadataPipe() {
246255
String path = config.get("player.metadataPipe");
247256
if (path == null || path.isEmpty()) return null;
248257
return new File(path);
@@ -261,42 +270,51 @@ private float normalisationPregain() {
261270
}
262271
}
263272

264-
private @Nullable String deviceId() {
273+
@Nullable
274+
private String deviceId() {
265275
String val = config.get("deviceId");
266276
return val == null || val.isEmpty() ? null : val;
267277
}
268278

269-
private @NotNull String deviceName() {
279+
@NotNull
280+
private String deviceName() {
270281
return config.get("deviceName");
271282
}
272283

273-
private @NotNull Connect.DeviceType deviceType() {
284+
@NotNull
285+
private Connect.DeviceType deviceType() {
274286
return config.getEnum("deviceType", Connect.DeviceType.class);
275287
}
276288

277-
private @NotNull String preferredLocale() {
289+
@NotNull
290+
private String preferredLocale() {
278291
return config.get("preferredLocale");
279292
}
280293

281-
private @NotNull String authUsername() {
294+
@NotNull
295+
private String authUsername() {
282296
return config.get("auth.username");
283297
}
284298

285-
private @NotNull String authPassword() {
299+
@NotNull
300+
private String authPassword() {
286301
return config.get("auth.password");
287302
}
288303

289-
private @NotNull String authBlob() {
304+
@NotNull
305+
private String authBlob() {
290306
return config.get("auth.blob");
291307
}
292308

293-
private @Nullable File credentialsFile() {
309+
@Nullable
310+
private File credentialsFile() {
294311
String path = config.get("auth.credentialsFile");
295312
if (path == null || path.isEmpty()) return null;
296313
return new File(path);
297314
}
298315

299-
public @NotNull Level loggingLevel() {
316+
@NotNull
317+
public Level loggingLevel() {
300318
return Level.toLevel(config.get("logLevel"));
301319
}
302320

@@ -309,11 +327,13 @@ public int apiPort() {
309327
return config.get("api.port");
310328
}
311329

312-
public @NotNull String apiHost() {
330+
@NotNull
331+
public String apiHost() {
313332
return config.get("api.host");
314333
}
315334

316-
public @NotNull ShellEvents.Configuration toEventsShell() {
335+
@NotNull
336+
public ShellEvents.Configuration toEventsShell() {
317337
return new ShellEvents.Configuration.Builder()
318338
.setEnabled(config.get("shell.enabled"))
319339
.setOnContextChanged(config.get("shell.onContextChanged"))
@@ -379,7 +399,7 @@ public Session.Builder initSessionBuilder() throws IOException, GeneralSecurityE
379399
public Session.Configuration toSession() {
380400
return new Session.Configuration.Builder()
381401
.setCacheEnabled(config.get("cache.enabled"))
382-
.setCacheDir(new File((String) config.get("cache.dir")))
402+
.setCacheDir(getFile("cache.dir"))
383403
.setDoCacheCleanUp(config.get("cache.doCleanUp"))
384404
.setStoreCredentials(config.get("auth.storeCredentials"))
385405
.setStoredCredentialsFile(credentialsFile())

pom.xml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,8 +56,7 @@
5656
<gson.version>2.8.6</gson.version>
5757
<protobuf.version>3.15.8</protobuf.version>
5858
<slf4j-api.version>1.7.30</slf4j-api.version>
59-
<log4j-core.version>2.13.3</log4j-core.version>
60-
<log4j-slf4j-impl.version>2.14.1</log4j-slf4j-impl.version>
59+
<log4j.version>2.14.1</log4j.version>
6160
<lmax-disruptor.version>3.4.3</lmax-disruptor.version>
6261
</properties>
6362

0 commit comments

Comments
 (0)