IOS-1540 For release, only log important messages. IOS-1540_GOOD
authorDirk Zimmermann <dz@pep.security>
Tue, 11 Jun 2019 16:28:31 +0200
branchIOS-1540_GOOD
changeset 90217f8083173e1d
parent 9020 716e8e8afd3e
child 9022 2bbceb04230d
IOS-1540 For release, only log important messages.
Submodules/pEpIOSToolbox/pEpIOSToolbox/Other/Logger.swift
     1.1 --- a/Submodules/pEpIOSToolbox/pEpIOSToolbox/Other/Logger.swift	Tue Jun 11 16:28:31 2019 +0200
     1.2 +++ b/Submodules/pEpIOSToolbox/pEpIOSToolbox/Other/Logger.swift	Tue Jun 11 16:28:31 2019 +0200
     1.3 @@ -267,18 +267,30 @@
     1.4                         filePath: String = #file,
     1.5                         fileLine: Int = #line,
     1.6                         args: [CVarArg]) {
     1.7 -        let theLog = osLogger as! OSLog
     1.8 -        let theType = severity.osLogType()
     1.9 +        var shouldLog = false
    1.10  
    1.11 -        let formatString = "\(message)".replacingOccurrences(of: "%{public}", with: "%")
    1.12 -        let ourString = String(format: formatString, arguments: args)
    1.13 +        #if DEBUG
    1.14 +        shouldLog = true
    1.15 +        #else
    1.16 +        if severity == .error || severity == .fault || severity == .default {
    1.17 +            shouldLog = true
    1.18 +        }
    1.19 +        #endif
    1.20  
    1.21 -        os_log("%{public}@:%d %{public}@: %{public}@",
    1.22 -               log: theLog,
    1.23 -               type: theType,
    1.24 -               filePath,
    1.25 -               fileLine,
    1.26 -               function,
    1.27 -               ourString)
    1.28 +        if shouldLog {
    1.29 +            let theLog = osLogger as! OSLog
    1.30 +            let theType = severity.osLogType()
    1.31 +
    1.32 +            let formatString = "\(message)".replacingOccurrences(of: "%{public}", with: "%")
    1.33 +            let ourString = String(format: formatString, arguments: args)
    1.34 +
    1.35 +            os_log("%{public}@:%d %{public}@: %{public}@",
    1.36 +                   log: theLog,
    1.37 +                   type: theType,
    1.38 +                   filePath,
    1.39 +                   fileLine,
    1.40 +                   function,
    1.41 +                   ourString)
    1.42 +        }
    1.43      }
    1.44  }