日志: 远程只收「启动检测 + 报错」,info/notice/warn 一律只写本地
- MiliLog 新增 remote()(启动检测专用,仍上远程);info/notice/warn 改为只写本地 - 启动检测 4 处改用 remote(): APP-INIT / BOOT / STORAGE / JS-BRIDGE ready - error 语义不变(报错仍上远程);local* 不变(只写本地) - 调用点名称不变,其余 40+ 处只是不再上传 - AGENTS 第 5 条日志约定重写;版本号 1.6.3(46) → 1.6.4(47) - 验证: assembleRelease + 单测 127 例全过
This commit is contained in:
+2
-2
@@ -20,8 +20,8 @@ android {
|
||||
applicationId "com.local.ktv"
|
||||
minSdk 21
|
||||
targetSdk 25
|
||||
versionCode 46
|
||||
versionName "1.6.3"
|
||||
versionCode 47
|
||||
versionName "1.6.4"
|
||||
ndk {
|
||||
// 双 ABI 打包:兼容 64 位(Exynos 1580 等 arm64-v8a)与 32 位设备(极米 Play 超越版
|
||||
// 的 Amlogic 950X2/S905X2 采用 32 位 Android 用户态,必须包含 armeabi-v7a,否则
|
||||
|
||||
@@ -31,7 +31,7 @@ class KtvApplication : Application() {
|
||||
// init 现在可重复调用且会自动重启发送线程,这里是"最靠前"的启动点。
|
||||
runCatching {
|
||||
MiliLog.init(this)
|
||||
MiliLog.info("APP-INIT 进程启动 ver=${BuildConfig.VERSION_NAME} logFile=${MiliLog.localLogPath()}")
|
||||
MiliLog.remote("APP-INIT 进程启动 ver=${BuildConfig.VERSION_NAME} logFile=${MiliLog.localLogPath()}")
|
||||
}.onFailure { Log.e(TAG, "MiliLog.init failed", it) }
|
||||
OkDownload.setSingletonInstance(OkDownload.Builder(this).build())
|
||||
Log.i(TAG, "KTV application initialized without native services")
|
||||
|
||||
@@ -287,7 +287,7 @@ class KtvJsBridge(context: Context) {
|
||||
unavailableReason = ""
|
||||
}
|
||||
Log.i(TAG, "JS runtime ready (${if (loadedFromCache) "cache" else "asset"})")
|
||||
MiliLog.info("JS-BRIDGE ready (${if (loadedFromCache) "cache" else "asset"})")
|
||||
MiliLog.remote("JS-BRIDGE ready (${if (loadedFromCache) "cache" else "asset"})")
|
||||
callback(true)
|
||||
} else if (loadedFromCache && !assetRetryAttempted) {
|
||||
Log.w(TAG, "Cached JS failed to load; falling back to packaged asset")
|
||||
|
||||
@@ -3878,10 +3878,10 @@ class MainActivity : AppCompatActivity() {
|
||||
sb.append(" screen=").append(screenResolutionText())
|
||||
// 等主机 IP(公网出口 IP)就绪,避免启动这条日志的 serverip 为空。
|
||||
MiliLog.awaitServerIp()
|
||||
MiliLog.notice(sb.toString())
|
||||
MiliLog.remote(sb.toString()) // BOOT 启动检测行
|
||||
// 存储根目录探测结果(排查不同盒子存储差异用;单行便于按 STORAGE 检索)。
|
||||
// 放在这里而不是启动主线程:既有完整上下文,又避免了主线程磁盘探测。
|
||||
runCatching { MiliLog.notice("STORAGE ${AppPaths.storageFacts(this@MainActivity)}") }
|
||||
runCatching { MiliLog.remote("STORAGE ${AppPaths.storageFacts(this@MainActivity)}") }
|
||||
} catch (ignored: Exception) {
|
||||
}
|
||||
}, "ktv-boot-log").start()
|
||||
|
||||
@@ -153,11 +153,25 @@ object MiliLog {
|
||||
}
|
||||
}
|
||||
|
||||
fun info(msg: String) = enqueue("INFO", msg)
|
||||
fun notice(msg: String) = enqueue("INFO", msg)
|
||||
fun warn(msg: String) = enqueue("WARN", msg)
|
||||
/**
|
||||
* ⚠️ **远程日志策略(2026-10-15 收紧,用户要求)**:远程服务**只收两类** ——
|
||||
* 1. **启动检测**:显式用 [remote](`APP-INIT` / `BOOT` / `STORAGE` / `JS-BRIDGE ready` 等一次性行);
|
||||
* 2. **报错**:[error]。
|
||||
*
|
||||
* 其余一切(info / notice / warn、逐源逐次细节、JS 控制台输出、6 小时健康样本……)
|
||||
* **只写本地** `<存储根>/logs/ktv.log`,不再上报远程。
|
||||
*
|
||||
* ⚠️ 不要顺手把 [info]/[notice]/[warn] 改回上传:远程只做"这台机器是否起来 + 有没有报错",
|
||||
* 需要细节时让现场把本地日志文件发出来(那里面什么都不缺)。
|
||||
*/
|
||||
fun info(msg: String) = enqueueLocal("INFO", msg)
|
||||
fun notice(msg: String) = enqueueLocal("INFO", msg)
|
||||
fun warn(msg: String) = enqueueLocal("WARN", msg)
|
||||
fun error(msg: String) = enqueue("ERROR", msg)
|
||||
|
||||
/** **启动检测**专用:这类一次性行仍上报远程(其余细节只写本地)。 */
|
||||
fun remote(msg: String) = enqueue("INFO", msg)
|
||||
|
||||
/**
|
||||
* **只写本地**的详细日志(2026-10 新增)。
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user