grape-middleware-logger 1.2.1 → 1.3.0

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 037217ed02fd0f73c8438b8c488cb52958ce78ed
4
- data.tar.gz: ed4e59b2e754b3e495c96a35e3463db8a19f0876
3
+ metadata.gz: 590ce26a5ad8498e9a23d0d04fb67d145839c3d2
4
+ data.tar.gz: 3b14c745464c253f07dc3f1d3114670ef69498f4
5
5
  SHA512:
6
- metadata.gz: 9a37f8ba7c40f25201a6102b2d63ca040ff4ace3ce77460b96b1ef8f2fbf743014e90f9d3014e10cf4f7d6d521e5fc8095991fabaef6243205ade1cb849d26f8
7
- data.tar.gz: 85df55e6c2f0581a3b56755f9088f55f6ef1cab952f9a2327fe1e88b62e8c80981f0e1114b0c523dbeb62332be1bee4dd0a06f2f2bbfa8372abcb6cac841ba6a
6
+ metadata.gz: 52bbc22b98b568a93abca85bb5037d5c01d21e791d15ed484ea8f03a3a895d15f6a251fd02bbe33d64b0b507db8850a07e52cb8c1244ae162fff67ef2328b94f
7
+ data.tar.gz: 2f7471095ee5ac2a94e9f98ca55e23d6656d6ff84126eb3860998b909484442e5adc97eb8b18217880cd10a4c849b7a14c72d68a85750751670f8ed8e51413bb
data/README.md CHANGED
@@ -20,13 +20,13 @@ class API < Grape::API
20
20
  end
21
21
  ```
22
22
 
23
+ Server requests will be logged to STDOUT by default.
24
+
23
25
  #### Rails
24
- Using Grape with Rails? `Rails.logger` will be used by default.
26
+ Using Grape with Rails? The `Rails.logger` will be used by default.
25
27
 
26
28
  #### Custom setup
27
- Want to customize the logging? You can provide a `logger` option.
28
-
29
- Example using a CustomLogger and parameter sanitization:
29
+ Customize the logging by passing the `logger` option. Example using a CustomLogger and parameter sanitization:
30
30
  ```ruby
31
31
  use Grape::Middleware::Logger, {
32
32
  logger: CustomLogger.new,
@@ -40,14 +40,14 @@ The `filter` option can be any object that responds to `.filter(params_hash)`
40
40
  ## Example output
41
41
  Get
42
42
  ```
43
- Started GET "/v1/reports/101"
43
+ Started GET "/v1/reports/101" at 2015-12-11 15:40:51 -0800
44
44
  Parameters: {"id"=>"101"}
45
45
  Completed 200 in 6.29ms
46
46
  ```
47
47
  Error
48
48
  ```
49
- Started GET "/v1/reports/101"
50
- Parameters: {"id"=>"101"}
49
+ Started POST "/v1/reports" at 2015-12-11 15:42:33 -0800
50
+ Parameters: {"name"=>"foo", "password"=>"[FILTERED]"}
51
51
  Error: {:error=>"undefined something something bad", :detail=>"Whoops"}
52
52
  Completed 422 in 6.29ms
53
53
  ```
@@ -2,7 +2,7 @@
2
2
 
3
3
  Gem::Specification.new do |spec|
4
4
  spec.name = 'grape-middleware-logger'
5
- spec.version = '1.2.1'
5
+ spec.version = '1.3.0'
6
6
  spec.platform = Gem::Platform::RUBY
7
7
  spec.authors = ['Ryan Buckley']
8
8
  spec.email = ['arebuckley@gmail.com']
@@ -15,7 +15,11 @@ class Grape::Middleware::Logger < Grape::Middleware::Globals
15
15
  start_time
16
16
  super # sets env['grape.*']
17
17
  logger.info ''
18
- logger.info %Q(Started #{env['grape.request'].request_method} "#{env['grape.request'].path}")
18
+ logger.info %Q(Started %s "%s" at %s) % [
19
+ env['grape.request'].request_method,
20
+ env['grape.request'].path,
21
+ start_time.to_s
22
+ ]
19
23
  logger.info %Q( Parameters: #{parameters})
20
24
  end
21
25
 
@@ -160,7 +160,7 @@ describe Grape::Middleware::Logger do
160
160
  expect(app).to receive(:call).with(env).and_return(app_response)
161
161
  expect(Grape::Request).to receive(:new).and_return(grape_request)
162
162
  expect(subject.logger).to receive(:info).with('')
163
- expect(subject.logger).to receive(:info).with(%Q(Started POST "/api/1.0/users"))
163
+ expect(subject.logger).to receive(:info).with(%Q(Started POST "/api/1.0/users" at #{subject.start_time}))
164
164
  expect(subject.logger).to receive(:info).with(%Q( Parameters: {"id"=>"101001", "name"=>"foo", "password"=>"[FILTERED]"}))
165
165
  expect(subject.logger).to receive(:info).with(/Completed 200 in \d.\d+ms/)
166
166
  expect(subject.logger).to receive(:info).with('')
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: grape-middleware-logger
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.1
4
+ version: 1.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ryan Buckley
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-12-09 00:00:00.000000000 Z
11
+ date: 2015-12-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: grape