2018-12-24 12:27:45 +00:00
|
|
|
package eu.faircode.email;
|
|
|
|
|
2018-12-31 08:04:33 +00:00
|
|
|
/*
|
|
|
|
This file is part of FairEmail.
|
|
|
|
|
|
|
|
FairEmail is free software: you can redistribute it and/or modify
|
|
|
|
it under the terms of the GNU General Public License as published by
|
|
|
|
the Free Software Foundation, either version 3 of the License, or
|
|
|
|
(at your option) any later version.
|
|
|
|
|
|
|
|
FairEmail is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
GNU General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
along with FairEmail. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
|
|
|
|
Copyright 2018-2019 by Marcel Bokhorst (M66B)
|
|
|
|
*/
|
|
|
|
|
2019-01-25 14:40:46 +00:00
|
|
|
import android.content.Intent;
|
|
|
|
import android.os.Bundle;
|
|
|
|
import android.text.TextUtils;
|
|
|
|
|
|
|
|
import java.util.Set;
|
|
|
|
|
2018-12-24 12:27:45 +00:00
|
|
|
public class Log {
|
|
|
|
static final String TAG = "fairemail";
|
|
|
|
|
|
|
|
public static int i(String msg) {
|
2018-12-28 09:56:40 +00:00
|
|
|
if (BuildConfig.BETA_RELEASE)
|
|
|
|
return android.util.Log.i(TAG, msg);
|
|
|
|
else
|
|
|
|
return 0;
|
2018-12-24 12:27:45 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
public static int w(String msg) {
|
|
|
|
return android.util.Log.w(TAG, msg);
|
|
|
|
}
|
|
|
|
|
|
|
|
public static int e(String msg) {
|
|
|
|
return android.util.Log.e(TAG, msg);
|
|
|
|
}
|
|
|
|
|
|
|
|
public static int w(Throwable ex) {
|
|
|
|
return android.util.Log.w(TAG, ex + "\n" + android.util.Log.getStackTraceString(ex));
|
|
|
|
}
|
|
|
|
|
|
|
|
public static int e(Throwable ex) {
|
|
|
|
return android.util.Log.e(TAG, ex + "\n" + android.util.Log.getStackTraceString(ex));
|
|
|
|
}
|
|
|
|
|
|
|
|
public static int w(String prefix, Throwable ex) {
|
|
|
|
return android.util.Log.w(TAG, prefix + " " + ex + "\n" + android.util.Log.getStackTraceString(ex));
|
|
|
|
}
|
|
|
|
|
|
|
|
public static int e(String prefix, Throwable ex) {
|
|
|
|
return android.util.Log.e(TAG, prefix + " " + ex + "\n" + android.util.Log.getStackTraceString(ex));
|
|
|
|
}
|
2019-01-25 14:40:46 +00:00
|
|
|
|
|
|
|
public static void logExtras(Intent intent) {
|
|
|
|
if (intent != null)
|
|
|
|
logBundle(intent.getExtras());
|
|
|
|
}
|
|
|
|
|
|
|
|
public static void logBundle(Bundle data) {
|
|
|
|
if (data != null) {
|
|
|
|
Set<String> keys = data.keySet();
|
|
|
|
StringBuilder stringBuilder = new StringBuilder();
|
|
|
|
for (String key : keys) {
|
|
|
|
Object value = data.get(key);
|
|
|
|
if (value instanceof String[])
|
|
|
|
value = TextUtils.join(", ", (String[]) value);
|
|
|
|
stringBuilder.append(key)
|
|
|
|
.append("=")
|
|
|
|
.append(value)
|
|
|
|
.append(value == null ? "" : " (" + value.getClass().getSimpleName() + ")")
|
|
|
|
.append("\r\n");
|
|
|
|
}
|
|
|
|
i(stringBuilder.toString());
|
|
|
|
}
|
|
|
|
}
|
2018-12-24 12:27:45 +00:00
|
|
|
}
|