fluent-logger 0.10.0 → 0.11.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 +4 -4
- data/.github/dependabot.yml +6 -0
- data/.github/workflows/linux.yml +22 -8
- data/.gitignore +1 -0
- data/ChangeLog +6 -0
- data/Gemfile.v0.12 +1 -1
- data/fluent-logger.gemspec +4 -0
- data/lib/fluent/logger/fluent_logger.rb +9 -1
- data/lib/fluent/logger/level_fluent_logger.rb +2 -1
- data/lib/fluent/logger/version.rb +1 -1
- data/spec/fluent_logger_spec.rb +26 -6
- data/spec/gemfiles/activesupport.gemfile +7 -0
- data/spec/gemfiles/no-activesupport.gemfile +4 -0
- metadata +11 -3
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 3df64fcf7bf38ee6e2e66c816279927a1fe6d9622a711c52b84a739745422e7c
|
|
4
|
+
data.tar.gz: dff1768c55cb33e57d01991ae91cad43ba752339c6f4db34582c06f9b0dfbf6e
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 82664c96b896ffbb37dc5d56292ef228db3c521a2c57736053b138ce75944524dad7d6c39616ede1a756d78859d51c2859ad45c2745c6cb78ee82b4de05d77d9
|
|
7
|
+
data.tar.gz: f9ccd114b9109fd2f3b06af62d03dc21c4d5e97c58555b9aa5dfc31ae491c13e67c605076c7cbedb03ab1a892d958d6f991d6a79197f8cea9e48201b5d19114b
|
data/.github/workflows/linux.yml
CHANGED
|
@@ -1,22 +1,36 @@
|
|
|
1
1
|
name: linux
|
|
2
2
|
on:
|
|
3
|
-
|
|
4
|
-
|
|
3
|
+
push:
|
|
4
|
+
branches: [master]
|
|
5
|
+
pull_request:
|
|
6
|
+
branches: [master]
|
|
7
|
+
schedule:
|
|
8
|
+
- cron: '0 0 1 * *'
|
|
5
9
|
jobs:
|
|
10
|
+
ruby-versions:
|
|
11
|
+
uses: ruby/actions/.github/workflows/ruby_versions.yml@master
|
|
12
|
+
with:
|
|
13
|
+
engine: cruby
|
|
14
|
+
min_version: 3.2
|
|
6
15
|
build:
|
|
16
|
+
needs: ruby-versions
|
|
7
17
|
runs-on: ${{ matrix.os }}
|
|
8
18
|
strategy:
|
|
9
19
|
fail-fast: false
|
|
10
20
|
matrix:
|
|
11
|
-
ruby:
|
|
12
|
-
|
|
13
|
-
-
|
|
14
|
-
- '3.4'
|
|
21
|
+
ruby: ${{ fromJson(needs.ruby-versions.outputs.versions) }}
|
|
22
|
+
exclude:
|
|
23
|
+
- ruby: head
|
|
15
24
|
os:
|
|
16
25
|
- ubuntu-latest
|
|
17
|
-
|
|
26
|
+
gemfile:
|
|
27
|
+
- activesupport
|
|
28
|
+
- no-activesupport
|
|
29
|
+
env:
|
|
30
|
+
BUNDLE_GEMFILE: spec/gemfiles/${{ matrix.gemfile }}.gemfile
|
|
31
|
+
name: Ruby ${{ matrix.ruby }} unit testing on ${{ matrix.os }} (${{ matrix.gemfile }})
|
|
18
32
|
steps:
|
|
19
|
-
- uses: actions/checkout@
|
|
33
|
+
- uses: actions/checkout@v7
|
|
20
34
|
- uses: ruby/setup-ruby@v1
|
|
21
35
|
with:
|
|
22
36
|
ruby-version: ${{ matrix.ruby }}
|
data/.gitignore
CHANGED
data/ChangeLog
CHANGED
data/Gemfile.v0.12
CHANGED
data/fluent-logger.gemspec
CHANGED
|
@@ -15,6 +15,10 @@ Gem::Specification.new do |gem|
|
|
|
15
15
|
gem.description = %q{fluent logger for ruby}
|
|
16
16
|
gem.summary = gem.description
|
|
17
17
|
|
|
18
|
+
gem.metadata['changelog_uri'] = "https://github.com/fluent/fluent-logger-ruby/blob/master/ChangeLog"
|
|
19
|
+
gem.metadata['source_code_uri'] = "https://github.com/fluent/fluent-logger-ruby"
|
|
20
|
+
gem.metadata['bug_tracker_uri'] = "https://github.com/fluent/fluent-logger-ruby/issues"
|
|
21
|
+
|
|
18
22
|
gem.files = `git ls-files`.split("\n")
|
|
19
23
|
gem.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
|
20
24
|
gem.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
|
@@ -49,6 +49,14 @@ module Fluent
|
|
|
49
49
|
def to_json(*args)
|
|
50
50
|
@sec.to_s
|
|
51
51
|
end
|
|
52
|
+
|
|
53
|
+
def as_json(*args)
|
|
54
|
+
# For ActiveSupport.
|
|
55
|
+
# By default, the custom classes are represented by their own instance variables.
|
|
56
|
+
# https://github.com/rails/rails/blob/87a9fdeef81f293cd972464686a6b4470ec642a2/activesupport/lib/active_support/core_ext/object/json.rb#L63
|
|
57
|
+
# Define it in a way that results in proper data structure when expressed in JSON
|
|
58
|
+
@sec
|
|
59
|
+
end
|
|
52
60
|
end
|
|
53
61
|
|
|
54
62
|
class FluentLogger < LoggerBase
|
|
@@ -235,7 +243,7 @@ module Fluent
|
|
|
235
243
|
res = begin
|
|
236
244
|
@packer.pack(msg).to_s
|
|
237
245
|
rescue NoMethodError
|
|
238
|
-
JSON.parse(
|
|
246
|
+
JSON.parse(msg.to_json).to_msgpack
|
|
239
247
|
ensure
|
|
240
248
|
@packer.clear
|
|
241
249
|
end
|
|
@@ -26,7 +26,8 @@ module Fluent
|
|
|
26
26
|
class LevelFluentLogger < ::Logger
|
|
27
27
|
|
|
28
28
|
def initialize(tag_prefix = nil, *args)
|
|
29
|
-
|
|
29
|
+
super(nil)
|
|
30
|
+
|
|
30
31
|
@default_formatter = proc do |severity, datetime, progname, message|
|
|
31
32
|
map = { level: severity }
|
|
32
33
|
map[:message] = message if message
|
data/spec/fluent_logger_spec.rb
CHANGED
|
@@ -8,6 +8,11 @@ require 'stringio'
|
|
|
8
8
|
require 'fluent/logger/fluent_logger/cui'
|
|
9
9
|
require 'timeout'
|
|
10
10
|
|
|
11
|
+
begin
|
|
12
|
+
require 'active_support/json'
|
|
13
|
+
rescue LoadError
|
|
14
|
+
end
|
|
15
|
+
|
|
11
16
|
describe Fluent::Logger::FluentLogger do
|
|
12
17
|
let(:fluentd) {
|
|
13
18
|
DummyFluentd.new
|
|
@@ -176,7 +181,12 @@ describe Fluent::Logger::FluentLogger do
|
|
|
176
181
|
logger.post('tag', data)
|
|
177
182
|
fluentd.wait_transfer
|
|
178
183
|
logger_data = fluentd.queue.last.last
|
|
179
|
-
|
|
184
|
+
if defined?(ActiveSupport)
|
|
185
|
+
expect(logger_data['time']).to eq '2008-09-01T10:05:00.000Z'
|
|
186
|
+
else
|
|
187
|
+
expect(logger_data['time']).to eq '2008-09-01 10:05:00 UTC'
|
|
188
|
+
end
|
|
189
|
+
|
|
180
190
|
expect(logger_data['proc']).to be_truthy
|
|
181
191
|
expect(logger_data['object']).to be_truthy
|
|
182
192
|
}
|
|
@@ -188,7 +198,11 @@ describe Fluent::Logger::FluentLogger do
|
|
|
188
198
|
fluentd.wait_transfer
|
|
189
199
|
|
|
190
200
|
logger_data1 = fluentd.queue.first.last
|
|
191
|
-
|
|
201
|
+
if defined?(ActiveSupport)
|
|
202
|
+
expect(logger_data1['time']).to eq '2008-09-01T10:05:00.000Z'
|
|
203
|
+
else
|
|
204
|
+
expect(logger_data1['time']).to eq '2008-09-01 10:05:00 UTC'
|
|
205
|
+
end
|
|
192
206
|
|
|
193
207
|
logger_data2 = fluentd.queue.last.last
|
|
194
208
|
expect(logger_data2['time']).to eq '2008-09-01 10:05:00 UTC'
|
|
@@ -199,13 +213,19 @@ describe Fluent::Logger::FluentLogger do
|
|
|
199
213
|
'time' => Time.utc(2008, 9, 1, 10, 5, 0),
|
|
200
214
|
'object' => Object.new,
|
|
201
215
|
'proc' => proc { 1 },
|
|
202
|
-
'NaN' => (0.0/0.0) # JSON don't convert
|
|
216
|
+
'NaN' => (0.0/0.0) # JSON don't convert by default
|
|
203
217
|
}
|
|
204
218
|
logger.post('tag', data)
|
|
205
219
|
fluentd.wait_transfer
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
220
|
+
if defined?(ActiveSupport)
|
|
221
|
+
# activesupport converts NaN to nil
|
|
222
|
+
# https://github.com/rails/rails/blob/90a1eaa1b30ba1f2d524e197460e549c03cf5698/activesupport/lib/active_support/core_ext/object/json.rb#L117-L118
|
|
223
|
+
expect(fluentd.queue.last).to eq ['logger-test.tag', {"NaN" => nil, "object" => {}, "proc" => {}, "time" => "2008-09-01T10:05:00.000Z"}]
|
|
224
|
+
else
|
|
225
|
+
expect(fluentd.queue.last).to be_nil
|
|
226
|
+
logger_io.rewind
|
|
227
|
+
expect(logger_io.read).to match(/FluentLogger: Can't convert to msgpack:/)
|
|
228
|
+
end
|
|
209
229
|
|
|
210
230
|
logger.post('tag', { 'a' => 'b' })
|
|
211
231
|
fluentd.wait_transfer
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: fluent-logger
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.
|
|
4
|
+
version: 0.11.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Sadayuki Furuhashi
|
|
@@ -50,6 +50,7 @@ executables:
|
|
|
50
50
|
extensions: []
|
|
51
51
|
extra_rdoc_files: []
|
|
52
52
|
files:
|
|
53
|
+
- ".github/dependabot.yml"
|
|
53
54
|
- ".github/workflows/linux.yml"
|
|
54
55
|
- ".gitignore"
|
|
55
56
|
- ".rspec"
|
|
@@ -75,6 +76,8 @@ files:
|
|
|
75
76
|
- lib/fluent/logger/version.rb
|
|
76
77
|
- spec/console_logger_spec.rb
|
|
77
78
|
- spec/fluent_logger_spec.rb
|
|
79
|
+
- spec/gemfiles/activesupport.gemfile
|
|
80
|
+
- spec/gemfiles/no-activesupport.gemfile
|
|
78
81
|
- spec/level_fluent_logger_spec.rb
|
|
79
82
|
- spec/logger_base_spec.rb
|
|
80
83
|
- spec/logger_spec.rb
|
|
@@ -88,7 +91,10 @@ files:
|
|
|
88
91
|
homepage: https://github.com/fluent/fluent-logger-ruby
|
|
89
92
|
licenses:
|
|
90
93
|
- Apache-2.0
|
|
91
|
-
metadata:
|
|
94
|
+
metadata:
|
|
95
|
+
changelog_uri: https://github.com/fluent/fluent-logger-ruby/blob/master/ChangeLog
|
|
96
|
+
source_code_uri: https://github.com/fluent/fluent-logger-ruby
|
|
97
|
+
bug_tracker_uri: https://github.com/fluent/fluent-logger-ruby/issues
|
|
92
98
|
rdoc_options: []
|
|
93
99
|
require_paths:
|
|
94
100
|
- lib
|
|
@@ -103,12 +109,14 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
103
109
|
- !ruby/object:Gem::Version
|
|
104
110
|
version: '0'
|
|
105
111
|
requirements: []
|
|
106
|
-
rubygems_version:
|
|
112
|
+
rubygems_version: 4.0.18
|
|
107
113
|
specification_version: 4
|
|
108
114
|
summary: fluent logger for ruby
|
|
109
115
|
test_files:
|
|
110
116
|
- spec/console_logger_spec.rb
|
|
111
117
|
- spec/fluent_logger_spec.rb
|
|
118
|
+
- spec/gemfiles/activesupport.gemfile
|
|
119
|
+
- spec/gemfiles/no-activesupport.gemfile
|
|
112
120
|
- spec/level_fluent_logger_spec.rb
|
|
113
121
|
- spec/logger_base_spec.rb
|
|
114
122
|
- spec/logger_spec.rb
|