@onekeyfe/react-native-native-logger 1.1.58 → 1.1.60
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -247,18 +247,19 @@ object OneKeyLog {
|
|
|
247
247
|
// Dedup: collapse identical consecutive messages into [N repeat]
|
|
248
248
|
// -----------------------------------------------------------------------
|
|
249
249
|
private val dedupLock = Any()
|
|
250
|
-
@Volatile private var
|
|
250
|
+
@Volatile private var prevLogKey: String? = null
|
|
251
251
|
private var repeatCount: Int = 0
|
|
252
252
|
|
|
253
253
|
private fun log(tag: String, level: String, message: String, androidLogLevel: Int) {
|
|
254
|
-
// Dedup identical consecutive messages
|
|
254
|
+
// Dedup identical consecutive messages (same level + tag + message)
|
|
255
|
+
val logKey = "$level:$tag:$message"
|
|
255
256
|
synchronized(dedupLock) {
|
|
256
|
-
if (
|
|
257
|
+
if (logKey == prevLogKey) {
|
|
257
258
|
repeatCount += 1
|
|
258
259
|
return
|
|
259
260
|
}
|
|
260
261
|
val pendingRepeat = repeatCount
|
|
261
|
-
|
|
262
|
+
prevLogKey = logKey
|
|
262
263
|
repeatCount = 0
|
|
263
264
|
|
|
264
265
|
if (pendingRepeat > 0) {
|
package/ios/OneKeyLog.swift
CHANGED
|
@@ -236,7 +236,7 @@ private class OneKeyLogFileManager: DDLogFileManagerDefault {
|
|
|
236
236
|
// Dedup: collapse identical consecutive messages into [N repeat]
|
|
237
237
|
// -----------------------------------------------------------------------
|
|
238
238
|
private static let dedupLock = NSLock()
|
|
239
|
-
private static var
|
|
239
|
+
private static var prevLogKey: String?
|
|
240
240
|
private static var repeatCount: Int = 0
|
|
241
241
|
|
|
242
242
|
private static func log(
|
|
@@ -247,16 +247,17 @@ private class OneKeyLogFileManager: DDLogFileManagerDefault {
|
|
|
247
247
|
) {
|
|
248
248
|
_ = configured
|
|
249
249
|
|
|
250
|
-
// Dedup identical consecutive messages
|
|
250
|
+
// Dedup identical consecutive messages (same level + tag + message)
|
|
251
|
+
let logKey = "\(level):\(tag):\(message)"
|
|
251
252
|
dedupLock.lock()
|
|
252
|
-
let isDuplicate = (
|
|
253
|
+
let isDuplicate = (logKey == prevLogKey)
|
|
253
254
|
if isDuplicate {
|
|
254
255
|
repeatCount += 1
|
|
255
256
|
dedupLock.unlock()
|
|
256
257
|
return
|
|
257
258
|
}
|
|
258
259
|
let pendingRepeat = repeatCount
|
|
259
|
-
|
|
260
|
+
prevLogKey = logKey
|
|
260
261
|
repeatCount = 0
|
|
261
262
|
dedupLock.unlock()
|
|
262
263
|
|