-
Notifications
You must be signed in to change notification settings - Fork 256
JSON renderer #46
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
JSON renderer #46
Changes from 3 commits
828f902
7df895d
8f31a76
13bc913
0b3d5b3
c76c63f
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,6 +1,7 @@ | ||
| # -*- coding: utf-8 -*- | ||
| import abc | ||
| import os | ||
| import json | ||
| from . import six | ||
|
|
||
| class Renderer(object): | ||
|
|
@@ -128,6 +129,21 @@ def render_frame(self, frame): | |
| result += '</div></div>' | ||
|
|
||
| return result | ||
|
|
||
| def _json_frame(frame): | ||
| return { | ||
| 'function': frame.function, | ||
| 'file_path': frame.file_path_short, | ||
|
||
| 'line_no': frame.line_no, | ||
| 'time': frame.time(), | ||
| 'children': [_json_frame(frame) for frame in frame.children] | ||
| } | ||
|
|
||
| class JSONRenderer(Renderer): | ||
| preferred_recorder = 'time_aggregating' | ||
|
|
||
| def render(self, frame): | ||
| return json.dumps(_json_frame(frame)) | ||
|
||
|
|
||
|
|
||
| class colors_enabled: | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can this be a method on the JSONRenderer object?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No problem