Skip to content

Instantly share code, notes, and snippets.

@cbowns
Created October 3, 2017 01:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cbowns/33ed5a25055f2b71b4facae703d4fad0 to your computer and use it in GitHub Desktop.
Save cbowns/33ed5a25055f2b71b4facae703d4fad0 to your computer and use it in GitHub Desktop.
/**
A custom destination to log SwiftyBeaver calls through to Bugfender.
Via http://support.bugfender.com/supported-logging-frameworks/swiftybeaver-support
*/
import Foundation
import SwiftyBeaver
import BugfenderSDK
public class BugfenderDestination: BaseDestination {
override public var defaultHashValue: Int { return 100 }
override public func send(_ level: SwiftyBeaver.Level, msg: String, thread: String, file: String, function: String, line: Int, context: Any?) -> String? {
var bfLogLevel: BFLogLevel? {
switch(level) {
case .error:
return BFLogLevel.error
case .warning:
return BFLogLevel.warning
case .info:
return BFLogLevel.default
default:
return nil
}
}
if let logLevel = bfLogLevel {
Bugfender.log(lineNumber: line, method: function, file: file, level: logLevel, tag: thread, message: msg)
}
return super.send(level, msg: msg, thread: thread, file: file, function: function, line: line)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment