This commit is contained in:
Ali 2022-09-20 13:25:57 +02:00
parent f145fc7cba
commit 5b1f01ce75
5 changed files with 25 additions and 6 deletions

View File

@ -642,7 +642,7 @@ private final class NotificationServiceHandler {
let logsPath = rootPath + "/logs/notification-logs"
let _ = try? FileManager.default.createDirectory(atPath: logsPath, withIntermediateDirectories: true, attributes: nil)
setupSharedLogger(rootPath: rootPath, path: logsPath)
setupSharedLogger(rootPath: logsPath, path: logsPath)
initializeAccountManagement()
@ -652,6 +652,24 @@ private final class NotificationServiceHandler {
let deviceSpecificEncryptionParameters = BuildConfig.deviceSpecificEncryptionParameters(rootPath, baseAppBundleId: baseAppBundleId)
self.encryptionParameters = ValueBoxEncryptionParameters(forceEncryptionIfNoSet: false, key: ValueBoxEncryptionParameters.Key(data: deviceSpecificEncryptionParameters.key)!, salt: ValueBoxEncryptionParameters.Salt(data: deviceSpecificEncryptionParameters.salt)!)
let semaphore = DispatchSemaphore(value: 0)
var loggingSettings = LoggingSettings.defaultSettings
let _ = (self.accountManager.transaction { transaction -> LoggingSettings in
if let value = transaction.getSharedData(SharedDataKeys.loggingSettings)?.get(LoggingSettings.self) {
return value
} else {
return LoggingSettings.defaultSettings
}
}).start(next: { value in
loggingSettings = value
semaphore.signal()
})
semaphore.wait()
Logger.shared.logToFile = loggingSettings.logToFile
Logger.shared.logToConsole = loggingSettings.logToConsole
Logger.shared.redactSensitiveData = loggingSettings.redactSensitiveData
let networkArguments = NetworkInitializationArguments(apiId: apiId, apiHash: apiHash, languagesCategory: languagesCategory, appVersion: appVersion, voipMaxLayer: 0, voipVersions: [], appData: .single(buildConfig.bundleData(withAppToken: nil, signatureDict: nil)), autolockDeadine: .single(nil), encryptionProvider: OpenSSLEncryptionProvider(), resolvedDeviceName: nil)

View File

@ -116,7 +116,7 @@ class DefaultIntentHandler: INExtension, INSendMessageIntentHandling, INSearchFo
let logsPath = rootPath + "/logs/siri-logs"
let _ = try? FileManager.default.createDirectory(atPath: logsPath, withIntermediateDirectories: true, attributes: nil)
setupSharedLogger(rootPath: rootPath, path: logsPath)
setupSharedLogger(rootPath: logsPath, path: logsPath)
let appVersion = (Bundle.main.infoDictionary?["CFBundleShortVersionString"] as? String) ?? "unknown"

View File

@ -94,7 +94,7 @@ private func getCommonTimeline(friends: [Friend]?, in context: TimelineProviderC
let logsPath = rootPath + "/logs/widget-logs"
let _ = try? FileManager.default.createDirectory(atPath: logsPath, withIntermediateDirectories: true, attributes: nil)
setupSharedLogger(rootPath: rootPath, path: logsPath)
setupSharedLogger(rootPath: logsPath, path: logsPath)
initializeAccountManagement()

View File

@ -573,7 +573,8 @@ private enum DebugControllerEntry: ItemListNodeEntry {
})
case .sendNotificationLogs:
return ItemListDisclosureItem(presentationData: presentationData, title: "Send Notification Logs (Up to 40 MB)", label: "", sectionId: self.section, style: .blocks, action: {
let _ = (Logger(rootPath: arguments.sharedContext.basePath, basePath: arguments.sharedContext.basePath + "/logs/notification-logs").collectLogs()
let logsPath = arguments.sharedContext.basePath + "/logs/notification-logs"
let _ = (Logger(rootPath: logsPath, basePath: logsPath).collectLogs()
|> deliverOnMainQueue).start(next: { logs in
let presentationData = arguments.sharedContext.currentPresentationData.with { $0 }
let actionSheet = ActionSheetController(presentationData: presentationData)
@ -721,7 +722,8 @@ private enum DebugControllerEntry: ItemListNodeEntry {
var logByType: [Signal<(type: String, logs: [(String, String)]), NoError>] = []
for type in logTypes {
logByType.append(Logger(rootPath: arguments.sharedContext.basePath, basePath: arguments.sharedContext.basePath + "/logs/\(type)").collectLogs()
let logsPath = arguments.sharedContext.basePath + "/logs/\(type)"
logByType.append(Logger(rootPath: logsPath, basePath: logsPath).collectLogs()
|> map { result -> (type: String, logs: [(String, String)]) in
return (type, result)
})

View File

@ -479,7 +479,6 @@ private func extractAccountManagerState(records: AccountRecordsView<TelegramAcco
TempBox.initializeShared(basePath: rootPath, processType: "app", launchSpecificId: Int64.random(in: Int64.min ... Int64.max))
let legacyLogs: [String] = [
"logs",
"broadcast-logs",
"siri-logs",
"widget-logs",