justlogging-rails 0.0.7 → 0.0.9
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.
@@ -41,7 +41,7 @@ module Justlogging
|
|
41
41
|
end
|
42
42
|
|
43
43
|
def formatted_exception
|
44
|
-
return {} unless
|
44
|
+
return {} unless exception?
|
45
45
|
{
|
46
46
|
:backtrace => @exception.backtrace,
|
47
47
|
:exception => @exception.name,
|
@@ -67,15 +67,25 @@ module Justlogging
|
|
67
67
|
:environment => Rails.env,
|
68
68
|
:server => @env['SERVER_NAME'],
|
69
69
|
:kind => 'http_request'
|
70
|
-
}.
|
70
|
+
}.merge(formatted_payload)
|
71
71
|
end
|
72
72
|
|
73
73
|
def formatted_payload
|
74
|
-
@log_entry
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
74
|
+
if @log_entry
|
75
|
+
{
|
76
|
+
:duration => @log_entry.duration,
|
77
|
+
:time => @log_entry.time,
|
78
|
+
:end => @log_entry.end
|
79
|
+
}.merge(@log_entry.payload).tap do |o|
|
80
|
+
o[:action] = "#{o.delete(:controller)}##{o[:action]}"
|
81
|
+
end
|
82
|
+
else
|
83
|
+
if exception?
|
84
|
+
{:action => @exception.inspect.gsub(/^<#(.*)>$/, '\1')}
|
85
|
+
else
|
86
|
+
{}
|
87
|
+
end
|
88
|
+
end
|
79
89
|
end
|
80
90
|
|
81
91
|
def to_hash
|
data/lib/justlogging/version.rb
CHANGED
@@ -110,35 +110,20 @@ describe Justlogging::Transaction do
|
|
110
110
|
|
111
111
|
describe '#formatted_log_entry' do
|
112
112
|
subject { transaction.formatted_log_entry }
|
113
|
-
before
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
before { transaction.stub(:exception? => false) }
|
118
|
-
before { transaction.stub(:formatted_payload => {:foo => :bar}) }
|
119
|
-
|
120
|
-
it 'returns a formatted log_entry' do
|
121
|
-
should == {
|
122
|
-
:name => '/blog',
|
123
|
-
:environment => 'care about it',
|
124
|
-
:server => 'localhost',
|
125
|
-
:kind => 'http_request',
|
126
|
-
:foo => :bar
|
127
|
-
}
|
128
|
-
end
|
113
|
+
before do
|
114
|
+
transaction.stub(:request => mock(:fullpath => '/blog'))
|
115
|
+
Rails.stub(:env => 'care about it')
|
116
|
+
transaction.stub(:formatted_payload => {:foo => :bar})
|
129
117
|
end
|
130
118
|
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
:kind => 'http_request'
|
140
|
-
}
|
141
|
-
end
|
119
|
+
it 'returns a formatted log_entry' do
|
120
|
+
should == {
|
121
|
+
:name => '/blog',
|
122
|
+
:environment => 'care about it',
|
123
|
+
:server => 'localhost',
|
124
|
+
:kind => 'http_request',
|
125
|
+
:foo => :bar
|
126
|
+
}
|
142
127
|
end
|
143
128
|
end
|
144
129
|
|
@@ -146,21 +131,38 @@ describe Justlogging::Transaction do
|
|
146
131
|
let(:start_time) { Time.parse('01-01-2001 10:00:00') }
|
147
132
|
let(:end_time) { Time.parse('01-01-2001 10:00:01') }
|
148
133
|
subject { transaction.formatted_payload }
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
134
|
+
|
135
|
+
context "with a present log entry" do
|
136
|
+
before do
|
137
|
+
transaction.set_log_entry(mock(
|
138
|
+
:name => 'name',
|
139
|
+
:duration => 2,
|
140
|
+
:time => start_time,
|
141
|
+
:end => end_time,
|
142
|
+
:payload => {:controller => 'controller', :action => 'action'}
|
143
|
+
))
|
144
|
+
end
|
145
|
+
|
146
|
+
it 'returns the formatted payload of the log entry' do
|
147
|
+
should == {
|
148
|
+
:action => 'controller#action',
|
149
|
+
:duration => 2,
|
150
|
+
:time => start_time,
|
151
|
+
:end => end_time
|
152
|
+
}
|
153
|
+
end
|
155
154
|
end
|
156
155
|
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
:
|
161
|
-
:
|
162
|
-
|
163
|
-
|
156
|
+
context "without a present log entry" do
|
157
|
+
|
158
|
+
it "returns the exception as the action if there is one" do
|
159
|
+
transaction.add_exception(mock(:inspect => '<#exceptional>'))
|
160
|
+
should == {:action => 'exceptional'}
|
161
|
+
end
|
162
|
+
|
163
|
+
it "returns an empty hash when no exception is set either" do
|
164
|
+
should == {}
|
165
|
+
end
|
164
166
|
end
|
165
167
|
end
|
166
168
|
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: justlogging-rails
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.9
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date: 2012-09-
|
13
|
+
date: 2012-09-17 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: rails
|