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 +4 -4
- data/lib/rack/fluentd_logger.rb +14 -5
- data/lib/rack/fluentd_logger_version.rb +1 -1
- metadata +5 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 073a72bcdbb58489f962c0cf526f0612136cbe242a65f7650459fe47ca46ac86
|
4
|
+
data.tar.gz: 05466ce5fb97bd22cd84339c34443487d34727b353b5735a53c81f9b14c9b864
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e5c9b2a5ebd2b5e0f4dc207281488a5fa3ae8383fc49cb2a3de2e6490aebce6b49b91afc12f9bcbc3016519c39dfd1d3612c61b96ce0a44e6bf9827b17ea59ec
|
7
|
+
data.tar.gz: cf9d08c1e711091eb945d0b983e32e620d5e13cfa4e0b49f8265a419a439f4591c8fea6235082d8c0c8886620c1b46f922f9d0d2d8d8ed635fc3df4418fcd1c0
|
data/lib/rack/fluentd_logger.rb
CHANGED
@@ -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']
|
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
|
|
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.
|
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:
|
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.
|
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.
|
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
|
-
|
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.
|