Open mkeremkeskin opened 6 years ago
the problem is nsarchive - it needs to be ripped out. @remirobert - lets fix this. it should be a couple of lines to switch out let dataArchive = NSKeyedArchiver.archivedData(withRootObject: logs)
and use a different storage provider my vote is to use https://github.com/pinterest/PINCache
class StoreManager<T> where T: NSCoding {
private let store: StoreManagerType
init(store: StoreManagerType) {
self.store = store
}
private func archiveLogs(logs: [T]) {
let dataArchive = NSKeyedArchiver.archivedData(withRootObject: logs)
UserDefaults.standard.set(dataArchive, forKey: store.rawValue)
UserDefaults.standard.synchronize()
}
func add(log: T) {
var logs = self.logs()
logs.append(log)
archiveLogs(logs: logs)
}
func save(logs: [T]) {
archiveLogs(logs: logs)
}
func logs() -> [T] {
guard let data = UserDefaults.standard.object(forKey: store.rawValue) as? NSData else {return []}
do {
let dataArchive = try NSKeyedUnarchiver.unarchiveTopLevelObjectWithData(data)
return dataArchive as? [T] ?? []
} catch {
return []
}
}
func reset() {
UserDefaults.standard.removeObject(forKey: store.rawValue)
UserDefaults.standard.synchronize()
}
}
@mkeremkeskin - you can use this https://github.com/PTEz/LumberjackConsole
Hey there,
I'm logging a lot of stuff like arrays etc. By using using Dotzu's print() (overrides standart version) method or Dotzu's Logger class methods, I observed that logs appearing on console really slow comparing to standard print() method.
I want to continue using Dotzu beacuse it's nice to see the logs on the app for our QA team. But this slow logging really affects my development routine. Do you have an idea what is the problem?
Btw I'm using the latest release of Dotzu and XCode 9. For earlier release of XCode 8 the was no problem. But I was facing the issue on latest XCode 8 version.
Thanks.