From 4e2a1b778bcb98cfb86afcf6d0c65d2121d8ff2a Mon Sep 17 00:00:00 2001 From: Andrew Brown Date: Thu, 2 Aug 2012 22:17:13 -0400 Subject: [PATCH] add params to entry, color different params value, hotkey p to change from inline to list layout --- .../rubyception/routers/log.coffee | 3 ++ .../javascripts/rubyception/template.js | 2 +- .../rubyception/views/entries/entry.coffee | 14 +++++++ .../stylesheets/rubyception/entries.sass | 37 ++++++++++++++++++- app/models/rubyception/entry.rb | 6 ++- app/views/rubyception/entries/_entry.haml | 1 + test/dummy/config/routes.rb | 2 +- 7 files changed, 60 insertions(+), 5 deletions(-) diff --git a/app/assets/javascripts/rubyception/routers/log.coffee b/app/assets/javascripts/rubyception/routers/log.coffee index a09ae4b..0537a72 100644 --- a/app/assets/javascripts/rubyception/routers/log.coffee +++ b/app/assets/javascripts/rubyception/routers/log.coffee @@ -30,6 +30,8 @@ class App.Routers.Log extends Backbone.Router @index() toggle_side: => $('.wrapper').toggleClass 'filter' + toggle_params: => + $('body').toggleClass 'pretty_params' hotkeys: => m = Mousetrap m.bind '\\ n' , @toggle_side @@ -38,6 +40,7 @@ class App.Routers.Log extends Backbone.Router m.bind String(i) , _.bind @log.entries_index.number_hotkey, @, String(i) for i in [0..9] m.bind 'shift+g' , _.bind @log.entries_index.goto_number, @, 'bottom' m.bind 'g g' , _.bind @log.entries_index.goto_number, @, 'top' + m.bind 'p' , @toggle_params m.bind ['o','enter'], @log.entries_index.toggle_open index: => App.column = @partial '.column', 'shared/filters' diff --git a/app/assets/javascripts/rubyception/template.js b/app/assets/javascripts/rubyception/template.js index 9f7c9ee..66954ea 100644 --- a/app/assets/javascripts/rubyception/template.js +++ b/app/assets/javascripts/rubyception/template.js @@ -1 +1 @@ -Template = {"entries":{"index":"
\n","entry":"
\n
\n
\n
{{method}}
\n
{{format}}
\n {{controller}}#{{action}}\n
{{path}}
\n
{{start_time}}
\n
{{duration}}ms
\n
\n
\n
\n
\n
\n"},"backtrace_lines":{"index":"\n \n \n \n \n \n
\n T\n \n {{name}}: {{message}}\n
\n","backtrace_line":"{{num}}\n{{msg}}\n{{line_num}}\n\n {{in}}\n\n"},"shared":{"filter_controller":"\n{{controller}}\n
\n","filter_action":"\n{{action}}\n"},"lines":{"index":"\n \n \n
\n","action_controller":{"write_fragment":"","read_fragment":"","expire_fragment":"","exist_fragment":"","write_page":"","expire_page":"","start_processing":"","process_action":"","send_file":"","send_data":"","redirect_to":"","halted_callback":""},"action_view":{"render_template":"render template\n{{identifier}}\n\n layout:\n {{layout}}\n\n{{duration}}ms\n","render_partial":"render partial\n{{identifier}}\n{{duration}}ms\n"},"active_record":{"sql":"{{name}}\n\n
{{sql}}
\n\n{{duration}}ms\n","identity":"{{name}}\n{{line}}\n{{duration}}ms\n"},"action_mailer":{"receive":"","deliver":""},"active_resource":{"request":""},"active_support":{"cache_read":"","cache_generate":"","cache_fetch_hit":"","cache_write":"","cache_delete":"","cache_exist":""}}} \ No newline at end of file +Template = {"entries":{"index":"
\n","entry":"
\n
\n
\n
{{method}}
\n
{{format}}
\n {{controller}}#{{action}}\n
{{path}}
\n
{{start_time}}
\n
{{duration}}ms
\n
\n
\n
\n
\n
\n
\n"},"backtrace_lines":{"index":"\n \n \n \n \n \n
\n T\n \n {{name}}: {{message}}\n
\n","backtrace_line":"{{num}}\n{{msg}}\n{{line_num}}\n\n {{in}}\n\n"},"shared":{"filter_controller":"\n{{controller}}\n
\n","filter_action":"\n{{action}}\n"},"lines":{"index":"\n \n \n
\n","action_controller":{"write_fragment":"","read_fragment":"","expire_fragment":"","exist_fragment":"","write_page":"","expire_page":"","start_processing":"","process_action":"","send_file":"","send_data":"","redirect_to":"","halted_callback":""},"action_view":{"render_template":"render template\n{{identifier}}\n\n layout:\n {{layout}}\n\n{{duration}}ms\n","render_partial":"render partial\n{{identifier}}\n{{duration}}ms\n"},"active_record":{"sql":"{{name}}\n\n
{{sql}}
\n\n{{duration}}ms\n","identity":"{{name}}\n{{line}}\n{{duration}}ms\n"},"action_mailer":{"receive":"","deliver":""},"active_resource":{"request":""},"active_support":{"cache_read":"","cache_generate":"","cache_fetch_hit":"","cache_write":"","cache_delete":"","cache_exist":""}}} \ No newline at end of file diff --git a/app/assets/javascripts/rubyception/views/entries/entry.coffee b/app/assets/javascripts/rubyception/views/entries/entry.coffee index 7557314..b12beb5 100644 --- a/app/assets/javascripts/rubyception/views/entries/entry.coffee +++ b/app/assets/javascripts/rubyception/views/entries/entry.coffee @@ -18,8 +18,22 @@ class App.Views.Entries.Entry extends Backbone.View @el_template 'entries/entry' @color_ms() @color_marker() + @params() @backtrace() @lines() + params:-> + params = @model.get 'params' + html = _.map params, (v,k)-> + boolean = v is true or v is false + number = !isNaN(parseFloat(v)) && isFinite(v) + kind = if boolean then 'boolean' + else if number then 'number' + else + v = "'#{v}'" + 'string' + + "#{k}: #{v}" + $(@el).find('.params').html html.join('') backtrace:-> backtrace = @model.get 'backtrace' if backtrace diff --git a/app/assets/stylesheets/rubyception/entries.sass b/app/assets/stylesheets/rubyception/entries.sass index fa54063..f18052a 100644 --- a/app/assets/stylesheets/rubyception/entries.sass +++ b/app/assets/stylesheets/rubyception/entries.sass @@ -45,17 +45,50 @@ :color rgb(50,250,100) .datetime :color rgb(120,120,120) - .lines, .backtrace_lines + .lines, .backtrace_lines, .params :display none &.ignore :display none &.selected :background rgb(55,55,55) &.open - .lines, .backtrace_lines + .lines, .backtrace_lines, .params :display block :padding-bottom 10px .position_marker :background rgb(255,0,0) :height 2px :margin 2px 0 + +.params + :padding 5px + :top 0px + :font-size 12px + .key + :color rgb(160,160,160) + .value + :margin + :left 5px + :right 10px + .string + :color rgb(0,200,100) + .number + :color rgb(0,100,200) + .boolean + :color rgb(200,200,0) + + +body.pretty_params + .open + .params + .param + :display block + //:display table + //:border-collapse collapse + //:border none + //.param + //:display table-row + //span + //:display table-cell + //.key, .colon + //:width 1% diff --git a/app/models/rubyception/entry.rb b/app/models/rubyception/entry.rb index 93cedca..8b5869e 100644 --- a/app/models/rubyception/entry.rb +++ b/app/models/rubyception/entry.rb @@ -28,7 +28,10 @@ def set_values event self.error = payload[:exception].present? self.duration = event.duration.to_f.round(2) self.id = event.transaction_id - self.params = payload[:params] + params = payload[:params] + params.delete 'controller' + params.delete 'action' + self.params = params self.start_time = event.time.to_s :entry self.end_time = event.end.to_s :entry end @@ -83,6 +86,7 @@ def finalize(event) def to_json methods = %w{controller + params action path method diff --git a/app/views/rubyception/entries/_entry.haml b/app/views/rubyception/entries/_entry.haml index 438f15d..ec7f1e3 100644 --- a/app/views/rubyception/entries/_entry.haml +++ b/app/views/rubyception/entries/_entry.haml @@ -7,6 +7,7 @@ .path {{path}} .datetime {{start_time}} .ms {{duration}}ms + .params .lines .backtrace_lines .clear diff --git a/test/dummy/config/routes.rb b/test/dummy/config/routes.rb index 06e97c1..98a0103 100644 --- a/test/dummy/config/routes.rb +++ b/test/dummy/config/routes.rb @@ -1,5 +1,5 @@ Rails.application.routes.draw do mount Rubyception::Engine => "/rubyception" - root to: 'tasks#index' + root to: 'tasks#index', all_done: true, project_name: 'Zeus', tasks_count: 235 end