Debug app log to file for troubleshooting
This commit is contained in:
parent
35db9ac53b
commit
5fb38652b0
|
@ -86,17 +86,37 @@ class AppConstants {
|
||||||
}
|
}
|
||||||
|
|
||||||
class Log {
|
class Log {
|
||||||
|
static let level: SwiftyBeaver.Level = .debug
|
||||||
|
|
||||||
static let debugFormat = "$DHH:mm:ss$d - $M"
|
static let debugFormat = "$DHH:mm:ss$d - $M"
|
||||||
|
|
||||||
static var debugSnapshot: () -> String = { TransientStore.shared.service.vpnLog }
|
static var debugSnapshot: () -> String = { TransientStore.shared.service.vpnLog }
|
||||||
|
|
||||||
static let viewerRefreshInterval: TimeInterval = 3.0
|
static let viewerRefreshInterval: TimeInterval = 3.0
|
||||||
|
|
||||||
|
private static let fileName = "Debug.log"
|
||||||
|
|
||||||
|
static var fileURL: URL {
|
||||||
|
return FileManager.default.userURL(for: .cachesDirectory, appending: fileName)
|
||||||
|
}
|
||||||
|
|
||||||
|
private static let console: ConsoleDestination = {
|
||||||
|
let dest = ConsoleDestination()
|
||||||
|
dest.minLevel = level
|
||||||
|
dest.useNSLog = true
|
||||||
|
return dest
|
||||||
|
}()
|
||||||
|
|
||||||
|
private static let file: FileDestination = {
|
||||||
|
let dest = FileDestination()
|
||||||
|
dest.minLevel = level
|
||||||
|
dest.logFileURL = fileURL
|
||||||
|
return dest
|
||||||
|
}()
|
||||||
|
|
||||||
static func configure() {
|
static func configure() {
|
||||||
let console = ConsoleDestination()
|
|
||||||
console.useNSLog = true
|
|
||||||
console.minLevel = .debug
|
|
||||||
SwiftyBeaver.addDestination(console)
|
SwiftyBeaver.addDestination(console)
|
||||||
|
SwiftyBeaver.addDestination(file)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue