grape-middleware-lograge 1.0.0 → 1.1.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: dd7eb695c21bda678be84d2daf06a7eb2c964668
4
- data.tar.gz: bee831a1a57cfcf2dd0291722f78bf29173b9486
3
+ metadata.gz: 0749b704c2396f878768bc0b2bc8680a2bc1680b
4
+ data.tar.gz: b9bdf6e794fd12569c935bb41082d8ace78f44e0
5
5
  SHA512:
6
- metadata.gz: b37a71953c1d02595cecf6c45417e2e050ebcb4959411c320db4a1fbc1a3bb68ba73bbf4972164a75635d9e15fe95ba6600e733c0a7e0c16931da983f846ae9d
7
- data.tar.gz: 61ff8930c61798b7ba78a22ac8140548b6d38656948f27901b65870d8c07a951fdff50d0bfce35685b1bc655c7080332980d293adc58b6fc0eb7612bc06b6b05
6
+ metadata.gz: b23a158180609730034d9764f504caef4153c578a52e58e039f851ae6866309000ed1bfc8cd83be728f161cc67e82de2e8f26d4e0a2f7d9f08821ec867ef961b
7
+ data.tar.gz: 1d71a59f35cab62b41ef938891879eeb32d0570793a53823bed4091492c584ee3b86cafcbc71cf0f6b69fa87d9333dc70f640c295712302118cbae324d7b574f
data/README.md CHANGED
@@ -1,6 +1,6 @@
1
- # A logger for Grape apps
2
- [![Code Climate](https://codeclimate.com/github/ridiculous/grape-middleware-logger/badges/gpa.svg)](https://codeclimate.com/github/ridiculous/grape-middleware-logger) [![Gem Version](https://badge.fury.io/rb/grape-middleware-logger.svg)](http://badge.fury.io/rb/grape-middleware-logger)
3
- [![Build Status](https://travis-ci.org/ridiculous/grape-middleware-logger.svg)](https://travis-ci.org/ridiculous/grape-middleware-logger)
1
+ # A logger for Grape apps that uses [Lograge](https://github.com/roidrage/lograge)
2
+ [![Code Climate](https://codeclimate.com/github/tchak/grape-middleware-lograge/badges/gpa.svg)](https://codeclimate.com/github/tchak/grape-middleware-lograge) [![Gem Version](https://badge.fury.io/rb/grape-middleware-lograge.svg)](http://badge.fury.io/rb/grape-middleware-lograge)
3
+ [![Build Status](https://travis-ci.org/tchak/grape-middleware-lograge.svg)](https://travis-ci.org/tchak/grape-middleware-lograge)
4
4
 
5
5
  Logs:
6
6
  * Request path
@@ -17,7 +17,7 @@ Add this line to your application's Gemfile:
17
17
 
18
18
  ```ruby
19
19
  gem 'grape', '>= 0.14.0'
20
- gem 'grape-middleware-logger'
20
+ gem 'grape-middleware-lograge'
21
21
  ```
22
22
 
23
23
  ## Usage
@@ -2,7 +2,7 @@
2
2
 
3
3
  Gem::Specification.new do |spec|
4
4
  spec.name = 'grape-middleware-lograge'
5
- spec.version = '1.0.0'
5
+ spec.version = '1.1.0'
6
6
  spec.platform = Gem::Platform::RUBY
7
7
  spec.authors = ['Ryan Buckley', 'Paul Chavard']
8
8
  spec.email = ['arebuckley@gmail.com', 'paul+github@chavard.net']
@@ -17,21 +17,29 @@ module Lograge
17
17
 
18
18
  lines = []
19
19
 
20
+ lines << started_request_message(data)
20
21
  lines << "Processing by #{data[:controller]}##{data[:action]} as #{format}"
21
22
  lines << " Parameters: #{params.inspect}" unless params.empty?
22
23
 
23
24
  lines
24
25
  end
25
26
 
27
+ def started_request_message(data)
28
+ 'Started %s "%s" for %s at %s' % [
29
+ data[:method],
30
+ data[:path],
31
+ data[:remote_ip],
32
+ Time.now.to_default_s ]
33
+ end
34
+
26
35
  def completed(data)
27
36
  status = data[:status]
28
-
29
- puts ActionDispatch::ExceptionWrapper.rescue_responses
37
+ duration = data[:duration].round
30
38
 
31
39
  if data[:error]
32
- "Exception #{status} #{data[:error]} after #{data[:duration].round}ms"
40
+ "Error #{status} #{data[:error]} after #{duration}ms"
33
41
  else
34
- "Completed #{status} #{Rack::Utils::HTTP_STATUS_CODES[status]} in #{data[:duration].round}ms"
42
+ "Completed #{status} #{Rack::Utils::HTTP_STATUS_CODES[status]} in #{duration}ms"
35
43
  end
36
44
  end
37
45
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: grape-middleware-lograge
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ryan Buckley
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2015-12-24 00:00:00.000000000 Z
12
+ date: 2015-12-25 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: grape