Skip to content

Instantly share code, notes, and snippets.

@jgimenez
Created October 19, 2016 10:09
Show Gist options
  • Save jgimenez/e533066cf3880fa5a6096df5dc8c940d to your computer and use it in GitHub Desktop.
Save jgimenez/e533066cf3880fa5a6096df5dc8c940d to your computer and use it in GitHub Desktop.
SwiftyBeaver destination to Bugfender

Install Bugfender normally using the instructions from the website. Then add to your SwiftyBeaver instance with:

let bugfender = BugfenderDestination()
log.addDestination(bugfender)
//
// BugfenderDestination.swift
// Bugfender
//
// Copyright by Bugfender Team
import Foundation
import SwiftyBeaver
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) -> String? {
var bfLogLevel: BFLogLevel {
switch(level) {
case .error:
return BFLogLevel.error
case .warning:
return BFLogLevel.warning
default:
return BFLogLevel.default
}
}
Bugfender.logLineNumber(line, method: function, file: file, level: bfLogLevel, 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