Created
December 10, 2015 21:00
-
-
Save jimrutherford/45223f46befd0de96589 to your computer and use it in GitHub Desktop.
SwiftyBeaver Crashlyitcs Log Destination
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// CrashlyticsDestination.swift | |
// | |
// Created by Jim Rutherford on 2015-12-10. | |
// | |
import UIKit | |
import Crashlytics | |
public class CrashlyticsDestination: BaseDestination { | |
override var defaultHashValue: Int {return 3} | |
public override init() { | |
super.init() | |
self.colored = false | |
} | |
// print to Xcode Console. uses full base class functionality | |
override func send(level: SwiftyBeaver.Level, msg: String, path: String, function: String, line: Int) -> String? { | |
let formattedString = super.send(level, msg: msg, path: path, function: function, line: line) | |
if let str = formattedString { | |
CLSLogv(str, getVaList([])) | |
} | |
return formattedString | |
} | |
} |
There will be a crash when str = "%d %@"
.
You should replace CLSLogv(str, getVaList([]))
with CLSLogv("%@", getVaList([ str ]))
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Here is a simple SwiftyBeaver logging destination that adds log messages to your Crashlytics crash reports