NekoX/TMessagesProj/src/main/java/org/telegram/messenger/FileLog.java

58 lines
1.5 KiB
Java
Raw Normal View History

2013-12-20 20:25:49 +01:00
/*
2019-01-23 18:03:33 +01:00
* This is the source code of Telegram for Android v. 5.x.x.
2013-12-20 20:25:49 +01:00
* It is licensed under GNU GPL v. 2 or later.
* You should have received a copy of the license in this archive (see LICENSE).
*
2019-01-23 18:03:33 +01:00
* Copyright Nikolai Kudashov, 2013-2018.
2013-12-20 20:25:49 +01:00
*/
package org.telegram.messenger;
import android.util.Log;
2020-07-30 14:11:37 +02:00
import cn.hutool.core.util.StrUtil;
2018-07-30 04:07:02 +02:00
2020-06-25 17:28:24 +02:00
public class FileLog {
2018-07-30 04:07:02 +02:00
2015-10-29 18:10:07 +01:00
public static String getNetworkLogPath() {
2021-03-18 08:48:00 +01:00
if (BuildVars.DEBUG_PRIVATE_VERSION) return "/dev/null";
2015-10-29 18:10:07 +01:00
return "";
}
2020-06-25 17:28:24 +02:00
private static String mkTag() {
2020-07-30 14:11:37 +02:00
final StackTraceElement[] stackTrace = Thread.currentThread().getStackTrace();
2020-12-24 17:33:17 +01:00
return StrUtil.subAfter(stackTrace[4].getClassName(), ".", true);
2020-07-30 14:11:37 +02:00
2020-06-25 17:28:24 +02:00
}
private static String mkMessage(Throwable e) {
String message = e.getMessage();
2021-02-19 06:34:01 +01:00
if (message != null) return e.getClass().getSimpleName() + ": " + message;
2020-06-25 17:28:24 +02:00
return e.getClass().getSimpleName();
2019-12-31 14:08:08 +01:00
}
2017-03-31 01:58:05 +02:00
public static void e(final String message, final Throwable exception) {
2020-06-25 17:28:24 +02:00
Log.e(mkTag(), message, exception);
2013-12-20 20:25:49 +01:00
}
2017-03-31 01:58:05 +02:00
public static void e(final String message) {
2020-06-25 17:28:24 +02:00
Log.e(mkTag(), message);
2013-12-20 20:25:49 +01:00
}
2017-03-31 01:58:05 +02:00
public static void e(final Throwable e) {
2020-07-30 14:11:37 +02:00
Log.e(mkTag(), mkMessage(e), e);
2013-12-20 20:25:49 +01:00
}
2017-03-31 01:58:05 +02:00
public static void d(final String message) {
2020-06-25 17:28:24 +02:00
if (!BuildVars.LOGS_ENABLED) return;
Log.d(mkTag(), message);
2013-12-20 20:25:49 +01:00
}
2017-03-31 01:58:05 +02:00
public static void w(final String message) {
2020-06-25 17:28:24 +02:00
if (!BuildVars.LOGS_ENABLED) return;
Log.w(mkTag(), message);
2015-02-01 19:51:02 +01:00
}
2013-12-20 20:25:49 +01:00
}