Created
October 3, 2017 01:03
-
-
Save cbowns/33ed5a25055f2b71b4facae703d4fad0 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
/** | |
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