IOS-1540 Logging forrmat string and [CVarArg]. IOS-1540_GOOD
authorDirk Zimmermann <dz@pep.security>
Tue, 11 Jun 2019 16:28:31 +0200
branchIOS-1540_GOOD
changeset 9014b6e5205bc054
parent 9013 9701654574df
child 9015 4682a3245ca2
IOS-1540 Logging forrmat string and [CVarArg].
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 @@ -227,8 +227,10 @@
     1.4      }
     1.5  
     1.6      /**
     1.7 -     - Note: If the number of arguments to the format string exceeds 10,
     1.8 -     the logging doesn't work correctly. Can be easily fixed though, if really needed.
     1.9 +     - Note: Logs in a format that is not pretty, but gets all the data across.
    1.10 +       The restrictions are given to `os_log`'s implementation,
    1.11 +       requiring a `StaticString`, which according to the documentation
    1.12 +       must be known at compile time.
    1.13       */
    1.14      private func osLog(message: StaticString,
    1.15                         severity: Severity,
    1.16 @@ -239,14 +241,14 @@
    1.17          let theLog = osLogger as! OSLog
    1.18          let theType = severity.osLogType()
    1.19  
    1.20 -        // I haven't found a way of injecting `function` etc. into the original message for
    1.21 -        // just one call to `os_log`, so the 'position' is logged on a separate line.
    1.22 -        os_log("%@:%d %@:",
    1.23 +        os_log("%{public}@:%d %{public}@: %{public}@ (%{public}@)",
    1.24                 log: theLog,
    1.25                 type: theType,
    1.26                 filePath,
    1.27                 fileLine,
    1.28 -               function)
    1.29 +               function,
    1.30 +               message,
    1.31 +               args)
    1.32  
    1.33          // We have to expand the array of arguments into positional ones.
    1.34          // There is no attempt of trying to format the string on our side