mirror of
https://github.com/fankes/termux-app.git
synced 2025-09-06 02:35:19 +08:00
Changed!: Remove TermuxConstants reference from Logger and set DEFAULT_LOG_TAG at application startup
Plugin apps must do the same
This commit is contained in:
@@ -6,9 +6,10 @@ import android.os.Looper;
|
||||
import android.util.Log;
|
||||
import android.widget.Toast;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
|
||||
import com.termux.shared.R;
|
||||
import com.termux.shared.data.DataUtils;
|
||||
import com.termux.shared.termux.TermuxConstants;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.PrintWriter;
|
||||
@@ -19,7 +20,7 @@ import java.util.List;
|
||||
|
||||
public class Logger {
|
||||
|
||||
public static final String DEFAULT_LOG_TAG = TermuxConstants.TERMUX_APP_NAME;
|
||||
private static String DEFAULT_LOG_TAG = "Logger";
|
||||
|
||||
public static final int LOG_LEVEL_OFF = 0; // log nothing
|
||||
public static final int LOG_LEVEL_NORMAL = 1; // start logging error, warn and info messages and stacktraces
|
||||
@@ -419,6 +420,20 @@ public class Logger {
|
||||
|
||||
|
||||
|
||||
@NonNull
|
||||
public static String getDefaultLogTag() {
|
||||
return DEFAULT_LOG_TAG;
|
||||
}
|
||||
|
||||
/**
|
||||
* IllegalArgumentException will be thrown if tag.length() > 23 for Nougat (7.0) and prior releases.
|
||||
* https://developer.android.com/reference/android/util/Log#isLoggable(java.lang.String,%20int) */
|
||||
public static void setDefaultLogTag(@NonNull String defaultLogTag) {
|
||||
DEFAULT_LOG_TAG = defaultLogTag.length() >= 23 ? defaultLogTag.substring(0, 22) : defaultLogTag;
|
||||
}
|
||||
|
||||
|
||||
|
||||
public static int getLogLevel() {
|
||||
return CURRENT_LOG_LEVEL;
|
||||
}
|
||||
|
@@ -190,7 +190,7 @@ public class StreamGobbler extends Thread {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
String defaultLogTag = Logger.DEFAULT_LOG_TAG;
|
||||
String defaultLogTag = Logger.getDefaultLogTag();
|
||||
boolean loggingEnabled = Logger.shouldEnableLoggingForCustomLogLevel(mLogLevel);
|
||||
if (loggingEnabled)
|
||||
Logger.logVerbose(LOG_TAG, "Using custom log level: " + mLogLevel + ", current log level: " + Logger.getLogLevel());
|
||||
|
Reference in New Issue
Block a user