Customize WireGuard debug log format

This commit is contained in:
Davide De Rosa 2022-03-24 08:59:48 +01:00
parent f1bdc8490c
commit 3bdff1ee8b
3 changed files with 5 additions and 3 deletions

View File

@ -813,7 +813,7 @@ extension OpenVPNTunnelProvider {
// MARK: Logging // MARK: Logging
private func configureLogging(debug: Bool, customFormat: String? = nil) { private func configureLogging(debug: Bool, customFormat: String?) {
let logLevel: SwiftyBeaver.Level = (debug ? debugLogLevel : .info) let logLevel: SwiftyBeaver.Level = (debug ? debugLogLevel : .info)
let logFormat = customFormat ?? "$Dyyyy-MM-dd HH:mm:ss.SSS$d $L $N.$F:$l - $M" let logFormat = customFormat ?? "$Dyyyy-MM-dd HH:mm:ss.SSS$d $L $N.$F:$l - $M"

View File

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

View File

@ -53,6 +53,8 @@ extension WireGuard {
public var shouldDebug = false public var shouldDebug = false
public var debugLogFormat: String? = nil
public init(_ title: String, appGroup: String, configuration: WireGuard.Configuration) { public init(_ title: String, appGroup: String, configuration: WireGuard.Configuration) {
self.title = title self.title = title
self.appGroup = appGroup self.appGroup = appGroup