Simplify .configureLogging() in app extensions

This commit is contained in:
Davide De Rosa 2022-06-16 20:54:48 +02:00
parent 61227fcb35
commit 178dda56ac
2 changed files with 10 additions and 13 deletions

View File

@ -173,10 +173,7 @@ open class OpenVPNTunnelProvider: NEPacketTunnelProvider {
} }
// prepare for logging (append) // prepare for logging (append)
configureLogging( configureLogging()
debug: cfg.shouldDebug,
customFormat: cfg.debugLogFormat
)
// logging only ACTIVE from now on // logging only ACTIVE from now on
log.info("") log.info("")
@ -814,11 +811,11 @@ extension OpenVPNTunnelProvider {
// MARK: Logging // MARK: Logging
private func configureLogging(debug: Bool, customFormat: String?) { private func configureLogging() {
let logLevel: SwiftyBeaver.Level = (debug ? debugLogLevel : .info) let logLevel: SwiftyBeaver.Level = (cfg.shouldDebug ? debugLogLevel : .info)
let logFormat = customFormat ?? "$Dyyyy-MM-dd HH:mm:ss.SSS$d $L $N.$F:$l - $M" let logFormat = cfg.debugLogFormat ?? "$Dyyyy-MM-dd HH:mm:ss.SSS$d $L $N.$F:$l - $M"
if debug { if cfg.shouldDebug {
let console = ConsoleDestination() let console = ConsoleDestination()
console.useNSLog = true console.useNSLog = true
console.minLevel = logLevel console.minLevel = logLevel

View File

@ -40,7 +40,7 @@ open class WireGuardTunnelProvider: NEPacketTunnelProvider {
return return
} }
configureLogging(debug: cfg.shouldDebug, customFormat: cfg.debugLogFormat) configureLogging()
// END: TunnelKit // END: TunnelKit
@ -125,11 +125,11 @@ open class WireGuardTunnelProvider: NEPacketTunnelProvider {
} }
extension WireGuardTunnelProvider { extension WireGuardTunnelProvider {
private func configureLogging(debug: Bool, customFormat: String?) { private func configureLogging() {
let logLevel: SwiftyBeaver.Level = (debug ? .debug : .info) let logLevel: SwiftyBeaver.Level = (cfg.shouldDebug ? .debug : .info)
let logFormat = customFormat ?? "$Dyyyy-MM-dd HH:mm:ss.SSS$d $L $N.$F:$l - $M" let logFormat = cfg.debugLogFormat ?? "$Dyyyy-MM-dd HH:mm:ss.SSS$d $L $N.$F:$l - $M"
if debug { if cfg.shouldDebug {
let console = ConsoleDestination() let console = ConsoleDestination()
console.useNSLog = true console.useNSLog = true
console.minLevel = logLevel console.minLevel = logLevel