request_recorder 0.0.7 → 0.0.8
Sign up to get free protection for your applications and to get access to all the features.
data/Gemfile.lock
CHANGED
@@ -1,6 +1,7 @@
|
|
1
1
|
require "stringio"
|
2
2
|
require "rack/request"
|
3
3
|
require "rack/response"
|
4
|
+
require "request_recorder/repeater"
|
4
5
|
|
5
6
|
module RequestRecorder
|
6
7
|
class Middleware
|
@@ -16,7 +17,7 @@ module RequestRecorder
|
|
16
17
|
def call(env)
|
17
18
|
# keep this part as fast as possible, since 99.99999% of requests will not need it
|
18
19
|
return @app.call(env) unless (
|
19
|
-
|
20
|
+
(env["QUERY_STRING"] && env["QUERY_STRING"].include?(MARKER)) or
|
20
21
|
(env["HTTP_COOKIE"] && env["HTTP_COOKIE"].include?(MARKER))
|
21
22
|
)
|
22
23
|
|
@@ -57,13 +58,16 @@ module RequestRecorder
|
|
57
58
|
end
|
58
59
|
|
59
60
|
def capture_logging
|
60
|
-
recorder = StringIO.new
|
61
61
|
old = [
|
62
62
|
ActiveRecord::Base.logger.instance_variable_get("@log"),
|
63
63
|
ActiveRecord::Base.logger.auto_flushing,
|
64
64
|
ActiveRecord::Base.logger.level
|
65
65
|
]
|
66
|
-
|
66
|
+
|
67
|
+
recorder = StringIO.new
|
68
|
+
repeater = Repeater.new([recorder, old[0]])
|
69
|
+
|
70
|
+
ActiveRecord::Base.logger.instance_variable_set("@log", repeater)
|
67
71
|
ActiveRecord::Base.logger.auto_flushing = true
|
68
72
|
ActiveRecord::Base.logger.level = Logger::DEBUG
|
69
73
|
yield
|
@@ -1,7 +1,7 @@
|
|
1
1
|
require "spec_helper"
|
2
2
|
|
3
3
|
describe RequestRecorder do
|
4
|
-
let(:original_logger){ ActiveSupport::BufferedLogger.new("/dev/null") }
|
4
|
+
let(:original_logger){ ActiveSupport::BufferedLogger.new("/dev/null").instance_variable_get("@log") }
|
5
5
|
let(:activate_logger){ {"QUERY_STRING" => "__request_recording=10"} }
|
6
6
|
let(:inner_app){ lambda{|env|
|
7
7
|
Car.first
|
@@ -31,6 +31,13 @@ describe RequestRecorder do
|
|
31
31
|
stored.values.last.should include "SELECT"
|
32
32
|
end
|
33
33
|
|
34
|
+
it "still writes to the old log to keep us compliant with 'logging all requests'" do
|
35
|
+
recorder = StringIO.new
|
36
|
+
ActiveRecord::Base.logger.instance_variable_set("@log", recorder)
|
37
|
+
middleware.call(activate_logger)
|
38
|
+
recorder.string.should == stored.values.last
|
39
|
+
end
|
40
|
+
|
34
41
|
it "starts with a given key" do
|
35
42
|
middleware.call({"QUERY_STRING" => "__request_recording=10|abcdefg"})
|
36
43
|
redis.hget(redis_key, "abcdefg").should include "SELECT"
|
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.0.
|
4
|
+
version: 0.0.8
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -42,6 +42,7 @@ files:
|
|
42
42
|
- lib/request_recorder/cache_logger.rb
|
43
43
|
- lib/request_recorder/middleware.rb
|
44
44
|
- lib/request_recorder/redis_logger.rb
|
45
|
+
- lib/request_recorder/repeater.rb
|
45
46
|
- lib/request_recorder/version.rb
|
46
47
|
- request_recorder.gemspec
|
47
48
|
- spec/request_recorder/cache_logger_spec.rb
|
@@ -63,7 +64,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
63
64
|
version: '0'
|
64
65
|
segments:
|
65
66
|
- 0
|
66
|
-
hash:
|
67
|
+
hash: 3361379851092162190
|
67
68
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
68
69
|
none: false
|
69
70
|
requirements:
|
@@ -72,7 +73,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
72
73
|
version: '0'
|
73
74
|
segments:
|
74
75
|
- 0
|
75
|
-
hash:
|
76
|
+
hash: 3361379851092162190
|
76
77
|
requirements: []
|
77
78
|
rubyforge_project:
|
78
79
|
rubygems_version: 1.8.24
|