Skip to content

Instantly share code, notes, and snippets.

@jimrutherford
Created December 10, 2015 21:00
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jimrutherford/45223f46befd0de96589 to your computer and use it in GitHub Desktop.
Save jimrutherford/45223f46befd0de96589 to your computer and use it in GitHub Desktop.
SwiftyBeaver Crashlyitcs Log Destination
//
// 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
}
}
@jimrutherford
Copy link
Author

Here is a simple SwiftyBeaver logging destination that adds log messages to your Crashlytics crash reports

@646b
Copy link

646b commented Mar 3, 2016

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