rack-fluentd-logger 0.1.0 → 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: f5f1b9cd4ad76b71bc6fbc7f42f7d21eb016f65c4f378b577c1713bf894ad4a4
4
- data.tar.gz: a8070a56def3ae1dc66c44e5a483e7250ed2d45d92863a88eeeabd3421eb12dc
3
+ metadata.gz: 073a72bcdbb58489f962c0cf526f0612136cbe242a65f7650459fe47ca46ac86
4
+ data.tar.gz: 05466ce5fb97bd22cd84339c34443487d34727b353b5735a53c81f9b14c9b864
5
5
  SHA512:
6
- metadata.gz: 357bfa292395d5ded226f3b246f39b821c01f29f1f763e4a16bcd9270c34c03e66d021a81a353fb805800b60dd6c9c66d4fa647a16c3f38f287fa06df45765cc
7
- data.tar.gz: a9329565200892d2e4840d9c58f1555fbc483429f4a1969f426a8ef9dd5a9fd703ed0cfd1eea5865e6535b5c1ac0272a5665bd71b61adc5b3373f2de79c4dbf4
6
+ metadata.gz: e5c9b2a5ebd2b5e0f4dc207281488a5fa3ae8383fc49cb2a3de2e6490aebce6b49b91afc12f9bcbc3016519c39dfd1d3612c61b96ce0a44e6bf9827b17ea59ec
7
+ data.tar.gz: cf9d08c1e711091eb945d0b983e32e620d5e13cfa4e0b49f8265a419a439f4591c8fea6235082d8c0c8886620c1b46f922f9d0d2d8d8ed635fc3df4418fcd1c0
@@ -1,5 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require 'English'
3
4
  require 'fluent-logger'
4
5
  require 'concurrent-ruby'
5
6
  require 'json'
@@ -33,10 +34,8 @@ module Rack
33
34
  def call(env)
34
35
  start = Time.now
35
36
  response = @app.call(env)
36
-
37
- log_request(env, response, Time.now - start)
38
-
39
- response
37
+ ensure
38
+ log_request(env, response || $ERROR_INFO, Time.now - start)
40
39
  end
41
40
 
42
41
  private
@@ -55,15 +54,25 @@ module Rack
55
54
  end
56
55
 
57
56
  def format_response(response)
57
+ return format_response_error(response) if response.is_a?(Error)
58
+
58
59
  code, headers, body = response
59
60
 
60
- if headers['Content-Type'] == 'application/json'
61
+ if headers['Content-Type'].start_with? 'application/json'
61
62
  body = body.map { |s| self.class.json_parser&.call(s) }
62
63
  end
63
64
 
64
65
  { code: code, body: body, headers: headers }
65
66
  end
66
67
 
68
+ def format_response_error(error)
69
+ {
70
+ class: error.class,
71
+ message: error.message,
72
+ backtrace: error.backtrace
73
+ }
74
+ end
75
+
67
76
  def drop_objects(obj)
68
77
  allowed = [Hash, Array, String, Numeric]
69
78
 
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Rack
4
4
  class FluentdLogger
5
- VERSION = '0.1.0'
5
+ VERSION = '0.1.1'
6
6
  end
7
7
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rack-fluentd-logger
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mikhail Slyusarev
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-12-01 00:00:00.000000000 Z
11
+ date: 2019-01-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rspec
@@ -44,14 +44,14 @@ dependencies:
44
44
  requirements:
45
45
  - - "~>"
46
46
  - !ruby/object:Gem::Version
47
- version: '1.1'
47
+ version: '1.0'
48
48
  type: :runtime
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
52
  - - "~>"
53
53
  - !ruby/object:Gem::Version
54
- version: '1.1'
54
+ version: '1.0'
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: fluent-logger
57
57
  requirement: !ruby/object:Gem::Requirement
@@ -95,8 +95,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
95
95
  - !ruby/object:Gem::Version
96
96
  version: '0'
97
97
  requirements: []
98
- rubyforge_project:
99
- rubygems_version: 2.7.7
98
+ rubygems_version: 3.0.2
100
99
  signing_key:
101
100
  specification_version: 4
102
101
  summary: Rack middleware for logging traffic to fluentd.