Skip to content

Instantly share code, notes, and snippets.

@OleksiiShvachenko
Created September 25, 2017 12:21
Show Gist options
  • Save OleksiiShvachenko/2be925ee9c6539b07c168acd7ccb4d12 to your computer and use it in GitHub Desktop.
Save OleksiiShvachenko/2be925ee9c6539b07c168acd7ccb4d12 to your computer and use it in GitHub Desktop.
public class DropboxDestination: BaseDestination {
private let client: DropboxClient
public init(accessToken: String) {
client = DropboxClient(accessToken: accessToken)
}
override public func send(_ level: SwiftyBeaver.Level, msg: String,
thread: String, file: String, function: String,
line: Int, context: Any?) -> String? {
let str = super.send(level, msg: msg, thread: thread,
file: file, function: function, line: line, context: context)!
let fileString = fileContent(message: msg).data(using: .utf8)!
let _ = client.files.upload(path: "/\(str).txt", autorename: true, input: fileString).response { (_, error) in
if let error = error {
print(error)
}
}
return str
}
private func fileContent(message: String) -> String {
let device = UIDevice.current
return """
Model: \(device.modelName)
System: \(device.systemName) \(device.systemVersion)
Message: \(message)
"""
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment