Feature: try add crash logger

This commit is contained in:
yicheng 2018-10-27 12:59:46 +08:00
parent 530fda3ade
commit aff909a966

View File

@ -44,6 +44,7 @@ class AppDelegate: NSObject, NSApplicationDelegate {
signal(SIGPIPE, SIG_IGN)
failLaunchProtect()
registCrashLogger()
_ = ProxyConfigManager.install()
ConfigFileFactory.upgardeIniIfNeed()
@ -163,6 +164,16 @@ class AppDelegate: NSObject, NSApplicationDelegate {
}
}
func registCrashLogger() {
func exceptionHandler(exception : NSException) {
print(exception)
print(exception.callStackSymbols)
let str = exception.callStackSymbols.joined(separator: "\n")
Logger.log(msg: str, level: .error)
}
NSSetUncaughtExceptionHandler(exceptionHandler)
}
func failLaunchProtect(){
let x = UserDefaults.standard
var launch_fail_times:Int = 0