@onekeyfe/react-native-native-logger 3.0.147 → 3.0.148
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.
- package/ios/OneKeyLog.swift +14 -2
- package/package.json +1 -1
package/ios/OneKeyLog.swift
CHANGED
|
@@ -96,6 +96,10 @@ private class OneKeyLogFileManager: DDLogFileManagerDefault {
|
|
|
96
96
|
|
|
97
97
|
private static let maxMessageLength = 4096
|
|
98
98
|
|
|
99
|
+
// Log retention, mirroring Android's MAX_FILE_SIZE / MAX_HISTORY / TOTAL_SIZE_CAP.
|
|
100
|
+
private static let maxLogFileSize: UInt64 = 20 * 1024 * 1024 // 20 MB
|
|
101
|
+
private static let maxLogFiles: UInt = 7 // 1 active + 6 archived
|
|
102
|
+
|
|
99
103
|
private struct TokenBucket {
|
|
100
104
|
let ratePerSecond: Double
|
|
101
105
|
let burstCapacity: Double
|
|
@@ -164,11 +168,19 @@ private class OneKeyLogFileManager: DDLogFileManagerDefault {
|
|
|
164
168
|
// NOTE: DDLogFileManagerDefault.maximumNumberOfLogFiles counts ALL log files
|
|
165
169
|
// including the current active file (app-latest.log).
|
|
166
170
|
// Set to 7 = 1 active + 6 archived, matching Android MAX_HISTORY=6.
|
|
167
|
-
fileManager.maximumNumberOfLogFiles =
|
|
171
|
+
fileManager.maximumNumberOfLogFiles = OneKeyLog.maxLogFiles
|
|
172
|
+
// logFilesDiskQuota defaults to 20 MB — the size of one full log file. The
|
|
173
|
+
// first roll then exceeds the quota, and because the rolled file is already
|
|
174
|
+
// archived, cleanup deletes every log file (the "don't delete the active
|
|
175
|
+
// file" guard only covers unarchived ones) and the logger writes nothing for
|
|
176
|
+
// the rest of the session. Size the quota after the retention above so a full
|
|
177
|
+
// set of files fits, matching Android's TOTAL_SIZE_CAP.
|
|
178
|
+
fileManager.logFilesDiskQuota =
|
|
179
|
+
UInt64(OneKeyLog.maxLogFiles) * OneKeyLog.maxLogFileSize
|
|
168
180
|
|
|
169
181
|
let logger = DDFileLogger(logFileManager: fileManager)
|
|
170
182
|
logger.rollingFrequency = 86400 // daily rolling
|
|
171
|
-
logger.maximumFileSize =
|
|
183
|
+
logger.maximumFileSize = OneKeyLog.maxLogFileSize
|
|
172
184
|
logger.logFormatter = OneKeyLogFormatter()
|
|
173
185
|
|
|
174
186
|
DDLog.add(logger)
|