mirror of
http://gitea.winboll.cc/Studio/WinBoLL.git
synced 2026-06-29 12:09:50 +08:00
修复调试模式初始化顺序及LogUtils空指针崩溃
- GlobalApplication: 调整restoreDebugStatus在initCoreComponents之前执行,确保调试标志先恢复再初始化日志 - LogUtils: init/setLogLevel/setTAG方法增加未初始化保护 - LogViewThread: getLogCacheDir空判断防止NPE
This commit is contained in:
@@ -1,8 +1,8 @@
|
|||||||
#Created by .winboll/winboll_app_build.gradle
|
#Created by .winboll/winboll_app_build.gradle
|
||||||
#Tue May 19 18:49:18 GMT 2026
|
#Wed May 20 03:05:29 CST 2026
|
||||||
stageCount=18
|
stageCount=18
|
||||||
libraryProject=libappbase
|
libraryProject=libappbase
|
||||||
baseVersion=15.20
|
baseVersion=15.20
|
||||||
publishVersion=15.20.17
|
publishVersion=15.20.17
|
||||||
buildCount=19
|
buildCount=24
|
||||||
baseBetaVersion=15.20.18
|
baseBetaVersion=15.20.18
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
#Created by .winboll/winboll_app_build.gradle
|
#Created by .winboll/winboll_app_build.gradle
|
||||||
#Tue May 19 18:49:18 GMT 2026
|
#Wed May 20 03:05:29 CST 2026
|
||||||
stageCount=18
|
stageCount=18
|
||||||
libraryProject=libappbase
|
libraryProject=libappbase
|
||||||
baseVersion=15.20
|
baseVersion=15.20
|
||||||
publishVersion=15.20.17
|
publishVersion=15.20.17
|
||||||
buildCount=19
|
buildCount=24
|
||||||
baseBetaVersion=15.20.18
|
baseBetaVersion=15.20.18
|
||||||
|
|||||||
@@ -129,11 +129,10 @@ public class GlobalApplication extends Application {
|
|||||||
// 初始化单例实例(确保在所有初始化操作前完成)
|
// 初始化单例实例(确保在所有初始化操作前完成)
|
||||||
sInstance = this;
|
sInstance = this;
|
||||||
|
|
||||||
|
restoreDebugStatus();
|
||||||
// 初始化基础组件(日志、崩溃处理、Toast)
|
// 初始化基础组件(日志、崩溃处理、Toast)
|
||||||
initCoreComponents();
|
initCoreComponents();
|
||||||
// 恢复/初始化调试模式状态(从本地文件读取,无文件则默认关闭调试)
|
// 初始化服务器地址(从 SP 读取到内存,提高后续访问效率)
|
||||||
restoreDebugStatus();
|
|
||||||
// 新增:初始化服务器地址(从 SP 读取到内存,提高后续访问效率)
|
|
||||||
initWinbollHost();
|
initWinbollHost();
|
||||||
|
|
||||||
LogUtils.d(TAG, "GlobalApplication 初始化完成,单例实例已创建");
|
LogUtils.d(TAG, "GlobalApplication 初始化完成,单例实例已创建");
|
||||||
|
|||||||
@@ -71,6 +71,9 @@ public class LogUtils {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static void init(final Context context, final LOG_LEVEL logLevel) {
|
public static void init(final Context context, final LOG_LEVEL logLevel) {
|
||||||
|
if (!GlobalApplication.isDebugging()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
Log.d(TAG, "init 执行日志工具初始化");
|
Log.d(TAG, "init 执行日志工具初始化");
|
||||||
_mContext = context;
|
_mContext = context;
|
||||||
|
|
||||||
@@ -247,6 +250,9 @@ public class LogUtils {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static void setTAGListEnable(final String tag, final boolean isEnable) {
|
public static void setTAGListEnable(final String tag, final boolean isEnable) {
|
||||||
|
if (!_IsInited) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
final Iterator<Map.Entry<String, Boolean>> iterator = mapTAGList.entrySet().iterator();
|
final Iterator<Map.Entry<String, Boolean>> iterator = mapTAGList.entrySet().iterator();
|
||||||
while (iterator.hasNext()) {
|
while (iterator.hasNext()) {
|
||||||
final Map.Entry<String, Boolean> entry = iterator.next();
|
final Map.Entry<String, Boolean> entry = iterator.next();
|
||||||
@@ -260,6 +266,9 @@ public class LogUtils {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static void setALlTAGListEnable(final boolean isEnable) {
|
public static void setALlTAGListEnable(final boolean isEnable) {
|
||||||
|
if (!_IsInited) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
for (final Map.Entry<String, Boolean> entry : mapTAGList.entrySet()) {
|
for (final Map.Entry<String, Boolean> entry : mapTAGList.entrySet()) {
|
||||||
entry.setValue(isEnable);
|
entry.setValue(isEnable);
|
||||||
}
|
}
|
||||||
@@ -269,6 +278,10 @@ public class LogUtils {
|
|||||||
|
|
||||||
// ====================== 日志级别控制 ======================
|
// ====================== 日志级别控制 ======================
|
||||||
public static void setLogLevel(final LOG_LEVEL logLevel) {
|
public static void setLogLevel(final LOG_LEVEL logLevel) {
|
||||||
|
if (_mLogUtilsBean == null) {
|
||||||
|
Log.d(TAG, "setLogLevel LogUtils未初始化,忽略设置日志级别");
|
||||||
|
return;
|
||||||
|
}
|
||||||
_mLogUtilsBean.setLogLevel(logLevel);
|
_mLogUtilsBean.setLogLevel(logLevel);
|
||||||
_mLogUtilsBean.saveBeanToFile(_mfLogUtilsBeanFile.getPath(), _mLogUtilsBean);
|
_mLogUtilsBean.saveBeanToFile(_mfLogUtilsBeanFile.getPath(), _mLogUtilsBean);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
package cc.winboll.studio.libappbase;
|
package cc.winboll.studio.libappbase;
|
||||||
|
|
||||||
import android.os.FileObserver;
|
import android.os.FileObserver;
|
||||||
|
import java.io.File;
|
||||||
import java.lang.ref.WeakReference;
|
import java.lang.ref.WeakReference;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -54,7 +55,12 @@ public class LogViewThread extends Thread {
|
|||||||
// 调试状态进行日志输出任务
|
// 调试状态进行日志输出任务
|
||||||
if (GlobalApplication.isDebugging()) {
|
if (GlobalApplication.isDebugging()) {
|
||||||
// 获取日志缓存目录路径(从 LogUtils 统一获取,确保路径一致性)
|
// 获取日志缓存目录路径(从 LogUtils 统一获取,确保路径一致性)
|
||||||
String logDirPath = LogUtils.getLogCacheDir().getPath();
|
File logDir = LogUtils.getLogCacheDir();
|
||||||
|
if (logDir == null) {
|
||||||
|
LogUtils.d(TAG, "日志缓存目录未初始化,线程退出");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
String logDirPath = logDir.getPath();
|
||||||
LogUtils.d(TAG, "启动日志文件监听,监听目录:" + logDirPath);
|
LogUtils.d(TAG, "启动日志文件监听,监听目录:" + logDirPath);
|
||||||
|
|
||||||
// 初始化日志文件监听器(监听目标目录的文件事件)
|
// 初始化日志文件监听器(监听目标目录的文件事件)
|
||||||
|
|||||||
Reference in New Issue
Block a user