log_spy 0.0.1 → 0.0.2
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.
- checksums.yaml +4 -4
- data/lib/log_spy/payload.rb +3 -1
- data/lib/log_spy/spy.rb +1 -1
- data/lib/log_spy/version.rb +1 -1
- data/spec/payload_spec.rb +7 -5
- data/spec/spy_spec.rb +4 -2
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 87ce664150f376cd71aca737ccb28dc70dad3990
|
4
|
+
data.tar.gz: b4f87234b6561e55e4ee6afbb3ee0faa53920d0c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d8564baac75a081c8d39b01cf58c3118947543e4a348885916cafc4e3fb0b171e397e1df07e48095cfbf72768bdd21405e9661ec73efdf0d7bb0f1fbc8c7758a
|
7
|
+
data.tar.gz: 70401bafdc79eb89cfb7f6590c12e06fa041be34e64b24e3334748b6cdb19c37c3b5515415b2f99ea9c6862009dc34ecec3769411f012d53c9d15bfd4ce76968
|
data/lib/log_spy/payload.rb
CHANGED
@@ -1,9 +1,10 @@
|
|
1
1
|
require 'json'
|
2
2
|
class LogSpy::Payload
|
3
|
-
def initialize req, res, error = nil
|
3
|
+
def initialize req, res, begin_at, error = nil
|
4
4
|
@req = req
|
5
5
|
@res = res
|
6
6
|
@error = error
|
7
|
+
@begin_at = begin_at
|
7
8
|
end
|
8
9
|
|
9
10
|
def to_json
|
@@ -13,6 +14,7 @@ class LogSpy::Payload
|
|
13
14
|
:path => @req.path,
|
14
15
|
:status => @res.status,
|
15
16
|
:execution_time => @res.duration,
|
17
|
+
:begin_at => @begin_at,
|
16
18
|
:request => {
|
17
19
|
:content_type => @req.content_type,
|
18
20
|
:request_method => @req.request_method,
|
data/lib/log_spy/spy.rb
CHANGED
data/lib/log_spy/version.rb
CHANGED
data/spec/payload_spec.rb
CHANGED
@@ -28,11 +28,12 @@ describe LogSpy::Payload do
|
|
28
28
|
end
|
29
29
|
|
30
30
|
let(:error) { Exception.new 'the-message' }
|
31
|
+
let(:begin_at) { Time.now.to_i }
|
31
32
|
|
32
|
-
describe '::new(request, response[, error = nil])' do
|
33
|
+
describe '::new(request, response, begin_at[, error = nil])' do
|
33
34
|
it 'takes a request, response and an optional error to init' do
|
34
|
-
payload = LogSpy::Payload.new
|
35
|
-
payload_with_err = LogSpy::Payload.new(request, response, error)
|
35
|
+
payload = LogSpy::Payload.new(request, response, begin_at)
|
36
|
+
payload_with_err = LogSpy::Payload.new(request, response, begin_at, error)
|
36
37
|
end
|
37
38
|
end
|
38
39
|
|
@@ -42,6 +43,7 @@ describe LogSpy::Payload do
|
|
42
43
|
:path => path,
|
43
44
|
:status => status,
|
44
45
|
:execution_time => duration,
|
46
|
+
:begin_at => begin_at,
|
45
47
|
:request => {
|
46
48
|
:content_type => content_type,
|
47
49
|
:request_method => request_method,
|
@@ -53,7 +55,7 @@ describe LogSpy::Payload do
|
|
53
55
|
end
|
54
56
|
|
55
57
|
context "if no error" do
|
56
|
-
let(:payload) { LogSpy::Payload.new request, response }
|
58
|
+
let(:payload) { LogSpy::Payload.new request, response, begin_at }
|
57
59
|
it 'returns correct format' do
|
58
60
|
expect(payload.to_json).to eq(expected_hash.to_json)
|
59
61
|
end
|
@@ -67,7 +69,7 @@ describe LogSpy::Payload do
|
|
67
69
|
end
|
68
70
|
|
69
71
|
context "if with error" do
|
70
|
-
let(:payload) { LogSpy::Payload.new request, response, error }
|
72
|
+
let(:payload) { LogSpy::Payload.new request, response, begin_at, error }
|
71
73
|
it 'returns error with message and backtrace' do
|
72
74
|
expected_hash[:error] = {
|
73
75
|
:message => error.message,
|
data/spec/spy_spec.rb
CHANGED
@@ -51,9 +51,10 @@ describe LogSpy::Spy do
|
|
51
51
|
end
|
52
52
|
|
53
53
|
it 'builds payload with request, status, request_time' do
|
54
|
-
expect(LogSpy::Payload).to receive(:new) do |req, res|
|
54
|
+
expect(LogSpy::Payload).to receive(:new) do |req, res, begin_at|
|
55
55
|
expect(req).to be(request)
|
56
56
|
expect(res.status).to eq(200)
|
57
|
+
expect(begin_at).to eq(now.to_i)
|
57
58
|
expect(res.duration).to eq((duration * 1000).round(0))
|
58
59
|
end
|
59
60
|
|
@@ -74,10 +75,11 @@ describe LogSpy::Spy do
|
|
74
75
|
end
|
75
76
|
|
76
77
|
it 'build payload with error' do
|
77
|
-
expect(LogSpy::Payload).to receive(:new) do |req, res, err|
|
78
|
+
expect(LogSpy::Payload).to receive(:new) do |req, res, begin_at, err|
|
78
79
|
expect(req).to be(request)
|
79
80
|
expect(res.status).to eq(500)
|
80
81
|
expect(res.duration).to eq(( duration * 1000 ).round(0))
|
82
|
+
expect(begin_at).to eq(now.to_i)
|
81
83
|
expect(err).to eq(error)
|
82
84
|
end
|
83
85
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: log_spy
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Yang-Hsing Lin
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-09-
|
11
|
+
date: 2014-09-03 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: aws-sdk
|