IOS-1540 Implement special errorAndCrash versions. IOS-1540_GOOD
authorDirk Zimmermann <dz@pep.security>
Tue, 11 Jun 2019 16:28:31 +0200
branchIOS-1540_GOOD
changeset 9017fa60d7acc4c8
parent 9016 0d06277e56e3
child 9018 6e79d0343779
IOS-1540 Implement special errorAndCrash versions.
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 @@ -161,12 +161,34 @@
     1.4                  args: args)
     1.5      }
     1.6  
     1.7 -    public func errorAndCrash(error: Error) {
     1.8 -        // TODO
     1.9 +    public func errorAndCrash(function: String = #function,
    1.10 +                              filePath: String = #file,
    1.11 +                              fileLine: Int = #line,
    1.12 +                              error: Error) {
    1.13 +        os_log("%{public}@:%d %{public}@: %{public}@",
    1.14 +               log: osLogger as! OSLog,
    1.15 +               type: .fault,
    1.16 +               filePath,
    1.17 +               fileLine,
    1.18 +               function,
    1.19 +               "\(error)")
    1.20 +
    1.21 +        SystemUtils.crash("\(filePath):\(fileLine) \(function): - \(error)")
    1.22      }
    1.23  
    1.24 -    public func errorAndCrash(message: String) {
    1.25 -        // TODO
    1.26 +    public func errorAndCrash(function: String = #function,
    1.27 +                              filePath: String = #file,
    1.28 +                              fileLine: Int = #line,
    1.29 +                              message: String) {
    1.30 +        os_log("%{public}@:%d %{public}@: %{public}@",
    1.31 +               log: osLogger as! OSLog,
    1.32 +               type: .fault,
    1.33 +               filePath,
    1.34 +               fileLine,
    1.35 +               function,
    1.36 +               "\(message)")
    1.37 +
    1.38 +        SystemUtils.crash("\(filePath):\(fileLine) \(function): - \(message)")
    1.39      }
    1.40  
    1.41      public func errorAndCrash(function: String = #function,