Created
September 25, 2017 12:21
-
-
Save OleksiiShvachenko/2be925ee9c6539b07c168acd7ccb4d12 to your computer and use it in GitHub Desktop.
This file contains 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
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