Skip to content

Commit

Permalink
v1.8
Browse files Browse the repository at this point in the history
  • Loading branch information
orhanobut committed Apr 13, 2015
1 parent 99d3aaf commit 8ef1e6b
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 16 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ Logger provides :

### Gradle
```groovy
compile 'com.orhanobut:logger:1.7'
compile 'com.orhanobut:logger:1.8'
```

### Current Log system
Expand Down
4 changes: 2 additions & 2 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@
# org.gradle.parallel=true

#VERSION_NAME=1.0-SNAPSHOT
VERSION_NAME=1.7
VERSION_CODE=8
VERSION_NAME=1.8
VERSION_CODE=9
GROUP=com.orhanobut

POM_DESCRIPTION=Simple,pretty and powerful log
Expand Down
20 changes: 7 additions & 13 deletions logger/src/main/java/com/orhanobut/logger/LoggerPrinter.java
Original file line number Diff line number Diff line change
Expand Up @@ -150,27 +150,24 @@ public void wtf(String message, Object... args) {
*/
@Override
public void json(String json) {
String tag = getTag();
int methodCount = getMethodCount();

if (TextUtils.isEmpty(json)) {
d(tag, "Empty/Null json content", methodCount);
d("Empty/Null json content");
return;
}
try {
if (json.startsWith("{")) {
JSONObject jsonObject = new JSONObject(json);
String message = jsonObject.toString(JSON_INDENT);
d(tag, message, methodCount);
d(message);
return;
}
if (json.startsWith("[")) {
JSONArray jsonArray = new JSONArray(json);
String message = jsonArray.toString(JSON_INDENT);
d(tag, message, methodCount);
d(message);
}
} catch (JSONException e) {
d(tag, e.getCause().getMessage() + "\n" + json, methodCount);
e(e.getCause().getMessage() + "\n" + json);
}
}

Expand All @@ -181,23 +178,20 @@ public void json(String json) {
*/
@Override
public void xml(String xml) {
String tag = getTag();
int methodCount = getMethodCount();
if (TextUtils.isEmpty(xml)) {
d(tag, "Empty/Null xml content", methodCount);
d("Empty/Null xml content");
return;
}

try {
Source xmlInput = new StreamSource(new StringReader(xml));
StreamResult xmlOutput = new StreamResult(new StringWriter());
Transformer transformer = TransformerFactory.newInstance().newTransformer();
transformer.setOutputProperty(OutputKeys.INDENT, "yes");
transformer.setOutputProperty("{http://xml.apache.org/xslt}indent-amount", "2");
transformer.transform(xmlInput, xmlOutput);
d(tag, xmlOutput.getWriter().toString().replaceFirst(">", ">\n"), methodCount);
d(xmlOutput.getWriter().toString().replaceFirst(">", ">\n"));
} catch (TransformerException e) {
d(tag, e.getCause().getMessage() + "\n" + xml, methodCount);
e(e.getCause().getMessage() + "\n" + xml);
}
}

Expand Down

0 comments on commit 8ef1e6b

Please sign in to comment.