Skip to content

Commit

Permalink
More updates for Swift 3 (changed NSError to Error and NSURL to URL)
Browse files Browse the repository at this point in the history
  • Loading branch information
Young Fan committed Jan 9, 2017
1 parent c7d831b commit a79a30e
Show file tree
Hide file tree
Showing 8 changed files with 17 additions and 17 deletions.
10 changes: 5 additions & 5 deletions AnalyticsKit.swift
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import Foundation
func logEvent(_ event: String, withProperties properties: [String: Any], timed: Bool)
func endTimedEvent(_ event: String, withProperties properties: [String: Any])
func logError(_ name: String, message: String?, exception: NSException?)
func logError(_ name: String, message: String?, error: NSError?)
func logError(_ name: String, message: String?, error: Error?)
}

class AnalyticsKit: NSObject {
Expand Down Expand Up @@ -104,7 +104,7 @@ class AnalyticsKit: NSObject {
channel(DefaultChannel).logError(name, message: message, exception: exception)
}

class func logError(_ name: String, message: String?, error: NSError?) {
class func logError(_ name: String, message: String?, error: Error?) {
channel(DefaultChannel).logError(name, message: message, error: error)
}

Expand Down Expand Up @@ -214,8 +214,8 @@ class AnalyticsKitChannel: NSObject, AnalyticsKitProvider {
}
}

func logError(_ name: String, message: String?, error: NSError?) {
AKLog("\(channelName) \(name) message: \(message ?? "nil") error: \(error?.description ?? "nil")")
func logError(_ name: String, message: String?, error: Error?) {
AKLog("\(channelName) \(name) message: \(message ?? "nil") error: \(error?.localizedDescription ?? "nil")")
for provider in providers {
provider.logError(name, message: message, error: error)
}
Expand All @@ -224,7 +224,7 @@ class AnalyticsKitChannel: NSObject, AnalyticsKitProvider {

private func AKLog(_ message: String, _ file: String = #file, _ function: String = #function, _ line: Int = #line) {
#if DEBUG
print("\(NSURL(string: file)?.lastPathComponent ?? "") \(function)[\(line)]: \(message)")
print("\(URL(string: file)?.lastPathComponent ?? "") \(function)[\(line)]: \(message)")
#else
if message == "" {
// Workaround for swift compiler optimizer crash
Expand Down
4 changes: 2 additions & 2 deletions AnalyticsKitDebugProvider.swift
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ class AnalyticsKitDebugProvider: NSObject, AnalyticsKitProvider {
showAlert(message)
}

func logError(_ name: String, message: String?, error: NSError?) {
let message = "\(name)\n\n\(message ?? "nil")\n\n\(error?.description ?? "nil")"
func logError(_ name: String, message: String?, error: Error?) {
let message = "\(name)\n\n\(message ?? "nil")\n\n\(error?.localizedDescription ?? "nil")"
showAlert(message)
}

Expand Down
2 changes: 1 addition & 1 deletion Providers/AdjustIO/AnalyticsKitAdjustIOProvider.swift
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ class AnalyticsKitAdjustIOProvider: NSObject, AnalyticsKitProvider {

}

func logError(_ name: String, message: String?, error: NSError?) {
func logError(_ name: String, message: String?, error: Error?) {

}

Expand Down
4 changes: 2 additions & 2 deletions Providers/Crashlytics/AnalyticsKitCrashlyticsProvider.swift
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,8 @@ class AnalyticsKitCrashlyticsProvider: NSObject, AnalyticsKitProvider {
clsLog("error: \(name) message: \(message ?? "nil") exception: \(exception?.description ?? "nil")")
}

func logError(_ name: String, message: String?, error: NSError?) {
clsLog("error: \(name) message: \(message ?? "nil") error: \(error?.description ?? "nil")")
func logError(_ name: String, message: String?, error: Error?) {
clsLog("error: \(name) message: \(message ?? "nil") error: \(error?.localizedDescription ?? "nil")")
}

fileprivate func clsLog(_ message: String) {
Expand Down
2 changes: 1 addition & 1 deletion Providers/Flurry/AnalyticsKitFlurryProvider.swift
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ class AnalyticsKitFlurryProvider: NSObject, AnalyticsKitProvider {
}
}

func logError(_ name: String, message: String?, error: NSError?) {
func logError(_ name: String, message: String?, error: Error?) {
runOnMainThread {
Flurry.logError(name, message: message, error: error)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ class AnalyticsKitWatchExtensionFlurryProvider: NSObject, AnalyticsKitProvider {

}

func logError(_ name: String, message: String?, error: NSError?) {
func logError(_ name: String, message: String?, error: Error?) {

}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,13 +73,13 @@ class AnalyticsKitGoogleAnalyticsProvider: NSObject, AnalyticsKitProvider {
}

func logError(_ name: String, message: String?, exception: NSException?) {
// isFatal = NO, presume here, Exeption is not fatal.
// isFatal = NO, presume here, Exception is not fatal.
let dict = GAIDictionaryBuilder.createException(withDescription: message ?? "nil", withFatal: 0).build() as [NSObject: AnyObject]
tracker.send(dict)
}

func logError(_ name: String, message: String?, error: NSError?) {
// isFatal = NO, presume here, Exeption is not fatal.
func logError(_ name: String, message: String?, error: Error?) {
// isFatal = NO, presume here, Exception is not fatal.
let dict = GAIDictionaryBuilder.createException(withDescription: message ?? "nil", withFatal: 0).build() as [NSObject: AnyObject]
tracker.send(dict)
}
Expand Down
4 changes: 2 additions & 2 deletions Providers/mParticle/AnalyticsKitMParticleProvider.swift
Original file line number Diff line number Diff line change
Expand Up @@ -85,13 +85,13 @@ class AnalyticsKitMParticleProvider: NSObject, AnalyticsKitProvider {
}
}

func logError(_ name: String, message: String?, error: NSError?) {
func logError(_ name: String, message: String?, error: Error?) {
var eventInfo = [String: Any]()
if let message = message {
eventInfo["message"] = message
}
if let error = error {
eventInfo["error"] = error.description
eventInfo["error"] = error.localizedDescription
}
MParticle.sharedInstance().logError(name, eventInfo: eventInfo)
}
Expand Down

0 comments on commit a79a30e

Please sign in to comment.