#XCGCrashlyticsLogDestination
###CocoaPods Add pre-install hook:
pre_install do |installer|
def installer.verify_no_static_framework_transitive_dependencies; end
end
and
pod 'XCGCrashlyticsLogDestination'
###What inside
####XCGCrashlyticsLogDestination
-
Writes your log into Crashlytics custom logs.
-
Can automatically convert your
.Severe
log to Crashlytics non-fatal errors (if you wish, ofcourse).
####XCGLogger
extension
error
andsevere
methods supportsNSError
.nonFatalError
method, that will pass yoursString
orNSError
to Crashlytics non-fatal errors, withoutXCGCrashlyticsLogDestination
.
###Usage
let log = XCGLoger(...
####XCGCrashlyticsLogDestination
Send all severe
logs to Crashlytics as non-fatal erors, and attach log to all errors, if they are occured:
let crashlyticsDestination =
XCGCrashlyticsLogDestination(owner: log,
identifier: "crashlyticsDestination",
outputToConsole: false,
recordSevereLogAsNonFalalErrors: true)
log.addLogDestination(crashlyticsDestination)
...
log.info("Yours message")
######Note: XCGCrashlyticsLogDestination
object overwrites Crashlytics.sharedInstance().delegate
on initialization to get crash report for last execution. It's better to have only one instance of XCGCrashlyticsLogDestination
.
####XCGLogger
extension
Log an occured NSError
, and send it to Crashlytics:
let error: NSError? = ...
log.nonFatalError(error)
or
log.nonFatalError {
...
let error: NSError? = ...
return error
}
or log an error String
, and send it to Crashlytics:
log.nonFatalError {
guard !somethingGood else { return nil }
return "Holy diver!"
}
and ofcourse:
log.error(`NSError`Object)
and
log.severe {
...
return `NSError`Object
}
###References
You can find more info on XCGLogger/Crashlytics (documentation and setup) here: