Last active
April 11, 2017 17:09
-
-
Save alanf/398cd7c803cc41e414554bb4d7687ca0 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 { | |
private let recorder: AWSFirehoseRecorder | |
init(recorder: AWSFirehoseRecorder = AWSFirehoseRecorder.default()) { | |
self.recorder = recorder | |
} | |
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