CarrotChat v2.8.60.240131版本的 MD5 值为:2baf8b9f31830b86b5c5a85ae6b47e05
以下内容为反编译后的 g.java 源代码,内容仅作参考
package b.k.a;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import java.io.StringReader;
import java.io.StringWriter;
import java.util.ArrayList;
import java.util.List;
import javax.xml.transform.Transformer;
import javax.xml.transform.TransformerException;
import javax.xml.transform.TransformerFactory;
import javax.xml.transform.stream.StreamResult;
import javax.xml.transform.stream.StreamSource;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
class g implements i {
private final ThreadLocal<String> a = new ThreadLocal<>();
private final List<c> f5442b = new ArrayList();
@NonNull
private String a(@NonNull String str, @Nullable Object... objArr) {
return (objArr == null || objArr.length == 0) ? str : String.format(str, objArr);
}
@Nullable
private String b() {
String str = this.a.get();
if (str != null) {
this.a.remove();
return str;
}
return null;
}
private synchronized void c(int i, @Nullable Throwable th, @NonNull String str, @Nullable Object... objArr) {
j.a(str);
log(i, b(), a(str, objArr), th);
}
@Override
public void addAdapter(@NonNull c cVar) {
this.f5442b.add(j.a(cVar));
}
@Override
public void clearLogAdapters() {
this.f5442b.clear();
}
@Override
public void d(@NonNull String str, @Nullable Object... objArr) {
c(3, null, str, objArr);
}
@Override
public void e(@NonNull String str, @Nullable Object... objArr) {
e(null, str, objArr);
}
@Override
public void i(@NonNull String str, @Nullable Object... objArr) {
c(4, null, str, objArr);
}
@Override
public void json(@Nullable String str) {
if (j.d(str)) {
d("Empty/Null json content");
return;
}
try {
String trim = str.trim();
if (trim.startsWith("{")) {
d(new JSONObject(trim).toString(2));
} else if (trim.startsWith("[")) {
d(new JSONArray(trim).toString(2));
} else {
e("Invalid Json", new Object[0]);
}
} catch (JSONException unused) {
e("Invalid Json", new Object[0]);
}
}
@Override
public synchronized void log(int i, @Nullable String str, @Nullable String str2, @Nullable Throwable th) {
if (th != null && str2 != null) {
str2 = str2 + " : " + j.c(th);
}
if (th != null && str2 == null) {
str2 = j.c(th);
}
if (j.d(str2)) {
str2 = "Empty/NULL log message";
}
for (c cVar : this.f5442b) {
if (cVar.isLoggable(i, str)) {
cVar.log(i, str, str2);
}
}
}
@Override
public i t(String str) {
if (str != null) {
this.a.set(str);
}
return this;
}
@Override
public void v(@NonNull String str, @Nullable Object... objArr) {
c(2, null, str, objArr);
}
@Override
public void w(@NonNull String str, @Nullable Object... objArr) {
c(5, null, str, objArr);
}
@Override
public void wtf(@NonNull String str, @Nullable Object... objArr) {
c(7, null, str, objArr);
}
@Override
public void xml(@Nullable String str) {
if (j.d(str)) {
d("Empty/Null xml content");
return;
}
try {
StreamSource streamSource = new StreamSource(new StringReader(str));
StreamResult streamResult = new StreamResult(new StringWriter());
Transformer newTransformer = TransformerFactory.newInstance().newTransformer();
newTransformer.setOutputProperty("indent", "yes");
newTransformer.setOutputProperty("{http://xml.apache.org/xslt}indent-amount", "2");
newTransformer.transform(streamSource, streamResult);
d(streamResult.getWriter().toString().replaceFirst(">", ">\n"));
} catch (TransformerException unused) {
e("Invalid xml", new Object[0]);
}
}
@Override
public void d(@Nullable Object obj) {
c(3, null, j.toString(obj), new Object[0]);
}
@Override
public void e(@Nullable Throwable th, @NonNull String str, @Nullable Object... objArr) {
c(6, th, str, objArr);
}
}