request_recorder 0.2.3 → 0.2.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- request_recorder (0.2.3)
4
+ request_recorder (0.2.4)
5
5
  activerecord
6
6
  multi_json
7
7
  rack
data/Readme.md CHANGED
@@ -14,7 +14,7 @@ Add to your middleware stack:
14
14
  :store => RequestRecorder::CacheLogger.new(Rails.cache),
15
15
  :frontend_auth => lambda { |env| Rails.env.development? } # TODO use something like `env.warden.user.is_admin?` in production
16
16
  # if you get 502's because of too large headers, you can reduce them: everything in :remove will be removed when above :max
17
- # :header => {:max => 10_000, :remove => [/SELECT count(\*)/, /SELECT \* FROM/, /Cache local read/, /Cache read/, /Identity Map/] }
17
+ # :headers => {:max => 10_000, :remove => [/Identity Map/, /Cache local read/, /Cache read/, /SELECT count(\*)/, /SELECT \* FROM/] }
18
18
 
19
19
  Usage
20
20
  =====
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: /Users/mgrosser/code/tools/request_recorder
3
3
  specs:
4
- request_recorder (0.2.2)
4
+ request_recorder (0.2.3)
5
5
  activerecord
6
6
  multi_json
7
7
  rack
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: /Users/mgrosser/code/tools/request_recorder
3
3
  specs:
4
- request_recorder (0.2.2)
4
+ request_recorder (0.2.3)
5
5
  activerecord
6
6
  multi_json
7
7
  rack
@@ -48,7 +48,8 @@ module RequestRecorder
48
48
  if result.is_a?(Exception)
49
49
  raise result # Do not mess up the apps normal exception behavior
50
50
  else
51
- extra_headers = chrome_logger_headers(log) if @auth && @auth.call(env)
51
+ path = [env["PATH_INFO"], env["QUERY_STRING"]].compact.join("?")
52
+ extra_headers = chrome_logger_headers(log, path) if @auth && @auth.call(env)
52
53
  response_with_data_in_cookie(result, steps_left, id, extra_headers)
53
54
  end
54
55
  end
@@ -95,14 +96,14 @@ module RequestRecorder
95
96
  response.finish # finish writes out the response in the expected format.
96
97
  end
97
98
 
98
- def chrome_logger_headers(log)
99
+ def chrome_logger_headers(log, path)
99
100
  log = log.split("\n").map { |line| remove_console_colors(line) }
100
101
  log = reduce_header_size(log) if @headers
101
102
 
102
103
 
103
104
  # fake chrome-logger format
104
105
  rows = []
105
- rows << [["Rails log"],"xxx.rb:1","group"]
106
+ rows << [["Rails log #{path}"],"xxx.rb:1","group"]
106
107
  rows.concat log.map{|line| [line.split(" "), "xxx.rb:1", ""] }
107
108
  rows << [[], "xxx.rb:1", "groupEnd"]
108
109
 
@@ -128,8 +129,10 @@ module RequestRecorder
128
129
  removed_count = 0
129
130
  removed_match = []
130
131
 
132
+ unimportant = (@headers[:remove] || []).dup
133
+
131
134
  while array.sum(&:size) > size
132
- if remove = (@headers[:remove] || []).pop
135
+ if remove = unimportant.shift
133
136
  removed_match << remove
134
137
  array.reject! { |line| line =~ remove }
135
138
  else
@@ -1,3 +1,3 @@
1
1
  module RequestRecorder
2
- VERSION = "0.2.3"
2
+ VERSION = "0.2.4"
3
3
  end
@@ -17,5 +17,14 @@ describe RequestRecorder::Middleware do
17
17
  "a" * 40, "c" * 40, "Removed: all /b/"
18
18
  ]
19
19
  end
20
+
21
+ it "can remove multiple times" do
22
+ middleware.send(:reduce_header_size, ["a" * 40,"b"*40,"c" * 40]).should == [
23
+ "a" * 40, "c" * 40, "Removed: all /b/"
24
+ ]
25
+ middleware.send(:reduce_header_size, ["a" * 40,"b"*40,"c" * 40]).should == [
26
+ "a" * 40, "c" * 40, "Removed: all /b/"
27
+ ]
28
+ end
20
29
  end
21
30
  end
@@ -187,7 +187,7 @@ describe RequestRecorder do
187
187
  "version"=>"0.1.1",
188
188
  "columns"=>["log", "backtrace", "type"],
189
189
  "rows"=>[
190
- [["Rails log"], "xxx.rb:1", "group"],
190
+ [["Rails log request_recorder=10-xxx"], "xxx.rb:1", "group"],
191
191
  [["Car", "Load", "---"], "xxx.rb:1", ""],
192
192
  [[], "xxx.rb:1", "groupEnd"]
193
193
  ]
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: request_recorder
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.3
4
+ version: 0.2.4
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -104,7 +104,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
104
104
  version: '0'
105
105
  segments:
106
106
  - 0
107
- hash: 542393427719907215
107
+ hash: 2258445014574956169
108
108
  required_rubygems_version: !ruby/object:Gem::Requirement
109
109
  none: false
110
110
  requirements:
@@ -113,7 +113,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
113
113
  version: '0'
114
114
  segments:
115
115
  - 0
116
- hash: 542393427719907215
116
+ hash: 2258445014574956169
117
117
  requirements: []
118
118
  rubyforge_project:
119
119
  rubygems_version: 1.8.25