Skip to content

Commit

Permalink
Move methods to the bottom
Browse files Browse the repository at this point in the history
  • Loading branch information
Konrad Dysput committed Oct 29, 2024
1 parent 2d5354a commit b7964b5
Showing 1 changed file with 45 additions and 45 deletions.
90 changes: 45 additions & 45 deletions backtracepython/report.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,51 @@ def set_exception(self, garbage, ex_value, ex_traceback):
self.faulting_thread_id = fault_thread_id
self.report["mainThread"] = self.faulting_thread_id

def capture_last_exception(self):
self.set_exception(*sys.exc_info())

def set_attribute(self, key, value):
self.report["attributes"][key] = value

def set_dict_attributes(self, target_dict):
self.report["attributes"].update(target_dict)

def set_annotation(self, key, value):
self.report["annotations"][key] = value

def get_annotations(self):
return self.report["annotations"]

def get_attributes(self):
return self.report["attributes"]

def set_dict_annotations(self, target_dict):
self.report["annotations"].update(target_dict)

def log(self, line):
self.log_lines.append(
{
"ts": time.time(),
"msg": line,
}
)

def add_attachment(self, attachment_path):
self.attachments.append(attachment_path)

def get_attachments(self):
return self.attachments

def get_data(self):
return self.report

def send(self):
if len(self.log_lines) != 0 and "Log" not in self.report["annotations"]:
self.report["annotations"]["Log"] = self.log_lines
from backtracepython.client import send

send(self)

def __generate_stack_trace(self):
current_frames = sys._current_frames()
threads = {}
Expand Down Expand Up @@ -120,48 +165,3 @@ def __convert_stack_trace(self, thread_stack_trace, skip_backtrace_module):
)

return stack_trace

def capture_last_exception(self):
self.set_exception(*sys.exc_info())

def set_attribute(self, key, value):
self.report["attributes"][key] = value

def set_dict_attributes(self, target_dict):
self.report["attributes"].update(target_dict)

def set_annotation(self, key, value):
self.report["annotations"][key] = value

def get_annotations(self):
return self.report["annotations"]

def get_attributes(self):
return self.report["attributes"]

def set_dict_annotations(self, target_dict):
self.report["annotations"].update(target_dict)

def log(self, line):
self.log_lines.append(
{
"ts": time.time(),
"msg": line,
}
)

def add_attachment(self, attachment_path):
self.attachments.append(attachment_path)

def get_attachments(self):
return self.attachments

def get_data(self):
return self.report

def send(self):
if len(self.log_lines) != 0 and "Log" not in self.report["annotations"]:
self.report["annotations"]["Log"] = self.log_lines
from backtracepython.client import send

send(self)

0 comments on commit b7964b5

Please sign in to comment.