Skip to content

Instantly share code, notes, and snippets.

@alanf
Last active April 11, 2017 17:11
Show Gist options
  • Select an option

  • Save alanf/43a3cb0c94f7d57ef2b7160197124711 to your computer and use it in GitHub Desktop.

Select an option

Save alanf/43a3cb0c94f7d57ef2b7160197124711 to your computer and use it in GitHub Desktop.
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