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)
configureLogging(
debug: cfg.shouldDebug,
customFormat: cfg.debugLogFormat
)
configureLogging()
// logging only ACTIVE from now on
log.info("")
@ -814,11 +811,11 @@ extension OpenVPNTunnelProvider {
// MARK: Logging
private func configureLogging(debug: Bool, customFormat: String?) {
let logLevel: SwiftyBeaver.Level = (debug ? debugLogLevel : .info)
let logFormat = customFormat ?? "$Dyyyy-MM-dd HH:mm:ss.SSS$d $L $N.$F:$l - $M"
private func configureLogging() {
let logLevel: SwiftyBeaver.Level = (cfg.shouldDebug ? debugLogLevel : .info)
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()
console.useNSLog = true
console.minLevel = logLevel

View File

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