Skip to content

Commit

Permalink
Merge pull request seanmonstar#8 from r-darwish/master
Browse files Browse the repository at this point in the history
Add push_tag to Event (fix seanmonstar#7)
  • Loading branch information
aagahi authored Dec 25, 2016
2 parents 4b20e07 + 21f16ae commit 7337fa3
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -256,6 +256,10 @@ impl Event {
fingerprint: fingerprint.unwrap_or(vec![]),
}
}

pub fn push_tag(&mut self, key: String, value: String) {
self.tags.push((key, value));
}
}

impl ToJsonString for Event {
Expand All @@ -281,9 +285,13 @@ impl ToJsonString for Event {
s.push_str(&format!(",\"release\":\"{}\"", release));
}
if self.tags.len() > 0 {
s.push_str(",\"tags\":\"{");
for tag in self.tags.iter() {
let last_index = self.tags.len() - 1;
s.push_str(",\"tags\":{");
for (index, tag) in self.tags.iter().enumerate() {
s.push_str(&format!("\"{}\":\"{}\"", tag.0, tag.1));
if index != last_index {
s.push_str(",");
}
}
s.push_str("}");
}
Expand Down Expand Up @@ -455,6 +463,10 @@ impl Sentry {
println!("Sentry Response {}", body);
}

pub fn log_event(&self, e: Event) {
self.worker.work_with(e);
}

pub fn register_panic_handler<F>(&self, maybe_f: Option<F>)
where F: Fn(&std::panic::PanicInfo) + 'static + Sync + Send
{
Expand Down

0 comments on commit 7337fa3

Please # to comment.