lograge 0.0.2 → 0.0.3
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/lib/lograge/log_subscriber.rb +14 -0
- data/lib/lograge/version.rb +1 -1
- data/spec/lograge_logsubscriber_spec.rb +28 -0
- metadata +9 -9
@@ -8,9 +8,14 @@ module Lograge
|
|
8
8
|
message = "#{payload[:method]} #{payload[:path]} format=#{payload[:format]} action=#{payload[:params]['controller']}##{payload[:params]['action']}"
|
9
9
|
message << extract_status(payload)
|
10
10
|
message << runtimes(event)
|
11
|
+
message << location(event)
|
11
12
|
logger.info(message)
|
12
13
|
end
|
13
14
|
|
15
|
+
def redirect_to(event)
|
16
|
+
Thread.current[:lograge_location] = event.payload[:location]
|
17
|
+
end
|
18
|
+
|
14
19
|
private
|
15
20
|
|
16
21
|
def extract_status(payload)
|
@@ -31,5 +36,14 @@ module Lograge
|
|
31
36
|
end
|
32
37
|
message
|
33
38
|
end
|
39
|
+
|
40
|
+
def location(event)
|
41
|
+
if location = Thread.current[:lograge_location]
|
42
|
+
Thread.current[:lograge_location] = nil
|
43
|
+
"location=#{location}"
|
44
|
+
else
|
45
|
+
""
|
46
|
+
end
|
47
|
+
end
|
34
48
|
end
|
35
49
|
end
|
data/lib/lograge/version.rb
CHANGED
@@ -77,5 +77,33 @@ describe Lograge::RequestLogSubscriber do
|
|
77
77
|
log_output.string.should =~ /status=500/
|
78
78
|
log_output.string.should =~ /error='AbstractController::ActionNotFound:Route not found'/
|
79
79
|
end
|
80
|
+
|
81
|
+
describe "with a redirect" do
|
82
|
+
before do
|
83
|
+
Thread.current[:lograge_location] = "http://www.example.com"
|
84
|
+
end
|
85
|
+
|
86
|
+
it "should add the location to the log line" do
|
87
|
+
subscriber.process_action(event)
|
88
|
+
log_output.string.should =~ %r{location=http://www.example.com}
|
89
|
+
end
|
90
|
+
|
91
|
+
it "should remove the thread local variable" do
|
92
|
+
subscriber.process_action(event)
|
93
|
+
Thread.current[:lograge_location].should == nil
|
94
|
+
end
|
95
|
+
end
|
96
|
+
|
97
|
+
it "should not include a location by default" do
|
98
|
+
subscriber.process_action(event)
|
99
|
+
log_output.string.should_not =~ /location=/
|
100
|
+
end
|
101
|
+
end
|
102
|
+
|
103
|
+
describe "when processing a redirect" do
|
104
|
+
it "should store the location in a thread local variable" do
|
105
|
+
subscriber.redirect_to(redirect)
|
106
|
+
Thread.current[:lograge_location].should == "http://example.com"
|
107
|
+
end
|
80
108
|
end
|
81
109
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: lograge
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.3
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -13,7 +13,7 @@ date: 2012-03-11 00:00:00.000000000 Z
|
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rspec
|
16
|
-
requirement: &
|
16
|
+
requirement: &70153872860480 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ! '>='
|
@@ -21,10 +21,10 @@ dependencies:
|
|
21
21
|
version: '0'
|
22
22
|
type: :development
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
24
|
+
version_requirements: *70153872860480
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: guard-rspec
|
27
|
-
requirement: &
|
27
|
+
requirement: &70153872859680 !ruby/object:Gem::Requirement
|
28
28
|
none: false
|
29
29
|
requirements:
|
30
30
|
- - ! '>='
|
@@ -32,10 +32,10 @@ dependencies:
|
|
32
32
|
version: '0'
|
33
33
|
type: :development
|
34
34
|
prerelease: false
|
35
|
-
version_requirements: *
|
35
|
+
version_requirements: *70153872859680
|
36
36
|
- !ruby/object:Gem::Dependency
|
37
37
|
name: activesupport
|
38
|
-
requirement: &
|
38
|
+
requirement: &70153872858340 !ruby/object:Gem::Requirement
|
39
39
|
none: false
|
40
40
|
requirements:
|
41
41
|
- - ! '>='
|
@@ -43,10 +43,10 @@ dependencies:
|
|
43
43
|
version: '0'
|
44
44
|
type: :runtime
|
45
45
|
prerelease: false
|
46
|
-
version_requirements: *
|
46
|
+
version_requirements: *70153872858340
|
47
47
|
- !ruby/object:Gem::Dependency
|
48
48
|
name: actionpack
|
49
|
-
requirement: &
|
49
|
+
requirement: &70153872856860 !ruby/object:Gem::Requirement
|
50
50
|
none: false
|
51
51
|
requirements:
|
52
52
|
- - ! '>='
|
@@ -54,7 +54,7 @@ dependencies:
|
|
54
54
|
version: '0'
|
55
55
|
type: :runtime
|
56
56
|
prerelease: false
|
57
|
-
version_requirements: *
|
57
|
+
version_requirements: *70153872856860
|
58
58
|
description: Tame Rails' multi-line logging into a single line per request
|
59
59
|
email:
|
60
60
|
- meyer@paperplanes.de
|