Last active
April 11, 2017 17:11
-
-
Save alanf/43a3cb0c94f7d57ef2b7160197124711 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
| class BreadcrumbLogger { | |
| let recorder = AWSFirehoseRecorder.default() | |
| private func breadcrumbDictionary(breadcrumb: Breadcrumb) -> Dictionary<String, AnyObject?> { | |
| let breadcrumbDictionary: Dictionary<String, AnyObject?> = [ | |
| /* snip */ | |
| :] | |
| return breadcrumbDictionary | |
| } | |
| func logBreadcrumbs(breadcrumbs: [Breadcrumb]) { | |
| for breadcrumb in breadcrumbs.map(breadcrumbDictionary) { | |
| let json = JSON(breadcrumb) | |
| let data = try? json.rawData() | |
| if let data = data { | |
| _ = recorder.saveRecord(data, streamName: BreadcrumbLoggerStreamName) | |
| } else { // log error | |
| } | |
| } | |
| _ = recorder.submitAllRecords() | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment