Skip to content
This repository was archived by the owner on Jan 5, 2019. It is now read-only.

Commit 0ad77de

Browse files
committed
Use slf4j, version 1.3!
1 parent 5e3a51c commit 0ad77de

3 files changed

Lines changed: 14 additions & 5 deletions

File tree

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ JavaRant is available on Maven, simply add this dependency to your `pom.xml` fil
88
<dependency>
99
<groupId>com.scorpiac.javarant</groupId>
1010
<artifactId>javarant</artifactId>
11-
<version>1.2</version>
11+
<version>1.3</version>
1212
</dependency>
1313
```
1414

pom.xml

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
<groupId>com.scorpiac.javarant</groupId>
88
<artifactId>javarant</artifactId>
9-
<version>1.2</version>
9+
<version>1.3</version>
1010
<packaging>jar</packaging>
1111

1212
<name>JavaRant</name>
@@ -44,6 +44,11 @@
4444
<artifactId>fluent-hc</artifactId>
4545
<version>4.5.1</version>
4646
</dependency>
47+
<dependency>
48+
<groupId>org.slf4j</groupId>
49+
<artifactId>slf4j-simple</artifactId>
50+
<version>1.7.21</version>
51+
</dependency>
4752
</dependencies>
4853

4954
<distributionManagement>

src/main/java/com/scorpiac/javarant/DevRant.java

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@
99
import org.apache.http.NameValuePair;
1010
import org.apache.http.client.fluent.Request;
1111
import org.apache.http.message.BasicNameValuePair;
12+
import org.slf4j.Logger;
13+
import org.slf4j.LoggerFactory;
1214

1315
import java.io.IOException;
1416
import java.io.InputStream;
@@ -22,6 +24,8 @@
2224
import java.util.stream.Collectors;
2325

2426
public class DevRant {
27+
private static final Logger LOGGER = LoggerFactory.getLogger(DevRant.class);
28+
2529
static final String APP_ID = "3";
2630
static final String PLAT_ID = "3";
2731

@@ -350,7 +354,7 @@ JsonObject get(String url, NameValuePair... params) {
350354
finalUrl.append('&').append(param.getName()).append('=').append(URLEncoder.encode(param.getValue(), "UTF-8"));
351355
} catch (UnsupportedEncodingException e) {
352356
// This never happens.
353-
e.printStackTrace();
357+
LOGGER.error("Unsupported encoding while trying to encode parameter value.", e);
354358
}
355359

356360
return executeRequest(Request.Get(BASE_URL + finalUrl.toString()));
@@ -394,15 +398,15 @@ private JsonObject executeRequest(Request request) {
394398
try {
395399
stream = request.socketTimeout(timeout).connectTimeout(timeout).execute().returnContent().asStream();
396400
} catch (IOException e) {
397-
e.printStackTrace();
401+
LOGGER.warn("Exception while processing request:\n" + request.toString() + '\n' + e.getMessage());
398402
return null;
399403
}
400404

401405
// Parse the response as json.
402406
try (JsonReader reader = new JsonReader(new InputStreamReader(stream))) {
403407
return new JsonParser().parse(reader).getAsJsonObject();
404408
} catch (IOException e) {
405-
e.printStackTrace();
409+
LOGGER.error("Exception while trying to create JsonReader.", e);
406410
return null;
407411
}
408412
}

0 commit comments

Comments
 (0)