rack-fluentd-logger 0.1.3 → 0.1.6

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
  SHA256:
3
- metadata.gz: 0204fc318ba727441f6ccfc3e8aa37d096af0e30ce0c90cec80ed8d800dc551b
4
- data.tar.gz: 4c4fd2a264b29efef84f2f3861fd1b992ac65da3412226c38c31a11b5fc5d532
3
+ metadata.gz: ddfafb67d58a7d6eb93ccdb74af42510b516f5aee1a61ea5a74b5d9ecb45df8b
4
+ data.tar.gz: 8c8755345bffaf5099ea537afb8ea01b860826f8706ae404d4dcd913545b7a76
5
5
  SHA512:
6
- metadata.gz: cc5923aed0db42d798764e2680e1d734b2067c88de94f96ad88b3124903385009fc633cb17d1b7743ce7b95175fbf95b7cb7ba4147a258aa2675e02afa553c6e
7
- data.tar.gz: e9a19f9e441ebc0633f4c83771c871d7616d394988ac3f47a85c274f4d7d3a45644341baf441dc1bba3bcb09d7d48f772790df5e0395db061a52926a8c2da5f5
6
+ metadata.gz: e0e1198104bb80f1d4b697c585ae60cc6c278888973948b4b336ed0ab624880c544de3db9cec9f1408d0c0be65a1c694cc6572a1073708fae78b52e89977cb14
7
+ data.tar.gz: 47dd423e3e24c1cc1bb373dcda3f1b79136e9cfdf19feefd35e2dc7688ce8beca72583ccc66c711b5f8391c2a68523db6fce2373fbb1e966eb71c11390d0f629
@@ -15,12 +15,14 @@ module Rack
15
15
  host: ENV['FLUENTD_HOST'],
16
16
  port: (ENV['FLUENTD_PORT'] || 24_224).to_i,
17
17
  json_parser: ->(str) { JSON.parse(str) },
18
- preprocessor: ->(d) { d }
18
+ preprocessor: ->(d) { d },
19
+ max_body_non_json: 256
19
20
  )
20
21
  @logger = Fluent::Logger::FluentLogger.new(name, host: host, port: port)
21
22
 
22
23
  @json_parser = json_parser
23
24
  @preprocessor = preprocessor
25
+ @max_body_non_json = max_body_non_json
24
26
  end
25
27
  end
26
28
 
@@ -58,9 +60,14 @@ module Rack
58
60
 
59
61
  code, headers, body = response
60
62
 
61
- if headers['Content-Type'].start_with? 'application/json'
62
- body = body.map { |s| self.class.json_parser&.call(s) }
63
- end
63
+ body = body.body if body.respond_to?(:body)
64
+ body = [body] if body.is_a? String
65
+
66
+ body = if headers['Content-Type'] && headers['Content-Type'].include? 'json'
67
+ body.map { |s| self.class.json_parser&.call(s) }
68
+ else
69
+ body[0..@max_body_non_json]
70
+ end
64
71
 
65
72
  { code: code, body: body, headers: headers }
66
73
  end
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Rack
4
4
  class FluentdLogger
5
- VERSION = '0.1.3'
5
+ VERSION = '0.1.6'
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.3
4
+ version: 0.1.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mikhail Slyusarev
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-02-22 00:00:00.000000000 Z
11
+ date: 2022-02-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rspec
@@ -66,7 +66,7 @@ dependencies:
66
66
  - - "~>"
67
67
  - !ruby/object:Gem::Version
68
68
  version: '0.7'
69
- description:
69
+ description:
70
70
  email:
71
71
  - slyusarevmikhail@gmail.com
72
72
  executables: []
@@ -80,7 +80,7 @@ homepage: https://github.com/mikhailvs/rack-fluentd-logger
80
80
  licenses:
81
81
  - MIT
82
82
  metadata: {}
83
- post_install_message:
83
+ post_install_message:
84
84
  rdoc_options: []
85
85
  require_paths:
86
86
  - lib
@@ -95,9 +95,8 @@ 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.3
100
- signing_key:
98
+ rubygems_version: 3.3.3
99
+ signing_key:
101
100
  specification_version: 4
102
101
  summary: Rack middleware for logging traffic to fluentd.
103
102
  test_files: []