SwiftyBeaver support
Jordi Giménez avatar
Written by Jordi Giménez
Updated over a week ago

SwiftyBeaver is a logging framework for iOS, macOS and tvOS. Bugfender can be configured as a logging destination so that you can use it in combination with it.

Here is how you do it:

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

let bugfender = BugfenderDestination()
log.addDestination(bugfender)
  • Create a BugfenderSwift.swift file in your project:

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) -> String? {
    var bfLogLevel: BFLogLevel {
      switch(level) {
      case .error:
        return BFLogLevel.error
      case .warning:
        return BFLogLevel.warning
      default:
        return BFLogLevel.default
      }
    }
    Bugfender.log(lineNumber: 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)
  }
}

Remember to install Bugfender in your AppDelegate as explained in the instructions. You may as well want to disable console printing if you use the SwiftyBeaver console destination:

Bugfender.setPrintToConsole(false)

Did this answer your question?