fluent-plugin-derive 0.0.1 → 0.0.2

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: 51798346dc27a15ff0a23c51c4926e146c3af789
4
- data.tar.gz: 16dc81bbc0e36994303602b7becc18ccf8091ff0
3
+ metadata.gz: 40df6241c18260283efffec5f0f93c244c34a40b
4
+ data.tar.gz: 5915919018654ad6c36a6bb55ec333f63165ac93
5
5
  SHA512:
6
- metadata.gz: d2a1c43275e27ea1e9a270c6dc35aba23fa89ffd200b6d23099920188ba8deb5e4528e74e767be24ff9cc3de82b911f4c492f4d813c578c2a5a69d16685ac411
7
- data.tar.gz: c13f6fede3c12711518daeb96131062032876e5a2528bf0acc6fc976a5ccf445866c509067ea771b45d8a6da67c45b40174498913ff753a114a6d544d81b3a95
6
+ metadata.gz: 24921c68f917045f314586080a70a35703e313b132ec4f1d610680c531674845fefc260b4b13c69648ca33b27d2eff6a1abac60e54b8819e6a577d94c2f5c4f2
7
+ data.tar.gz: c99527ac6b9b5479e4f5a6d2cf252473439135390110757aa495934e0da1b029c108bfdad16be77442b890f8282a9776b242942d87f96512d7df7adaa6041412
data/.travis.yml CHANGED
@@ -2,5 +2,7 @@ rvm:
2
2
  - 1.9.2
3
3
  - 1.9.3
4
4
  - 2.0.0
5
+ - 2.1.0
5
6
  gemfile:
6
7
  - Gemfile
8
+ - Gemfile.fluentd.lt.0.10.43
data/CHANGELOG.md ADDED
@@ -0,0 +1,10 @@
1
+ # 0.0.2 (2014/02/07)
2
+
3
+ Enhancement:
4
+
5
+ * Support plugin specific log_level
6
+
7
+ # 0.0.1 (2013/12/25)
8
+
9
+ Initial Release
10
+
@@ -0,0 +1,8 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # fluentd 0.10.43 or later supports log_level configuration attribute.
4
+ # This tests lt 0.10.43 on travis ci.
5
+ gem 'fluentd', '= 0.10.42'
6
+
7
+ # Specify your gem's dependencies in fluent-plugin-derive.gemspec
8
+ gemspec
data/Rakefile CHANGED
@@ -1 +1,8 @@
1
1
  require "bundler/gem_tasks"
2
+
3
+ require 'rspec/core'
4
+ require 'rspec/core/rake_task'
5
+ RSpec::Core::RakeTask.new(:spec) do |spec|
6
+ spec.pattern = FileList['spec/**/*_spec.rb']
7
+ end
8
+ task :default => :spec
@@ -4,7 +4,7 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
4
 
5
5
  Gem::Specification.new do |spec|
6
6
  spec.name = "fluent-plugin-derive"
7
- spec.version = "0.0.1"
7
+ spec.version = "0.0.2"
8
8
  spec.authors = ["Nobuhiro Nikushi"]
9
9
  spec.email = ["deneb.ge@gmail.com"]
10
10
  spec.description = spec.summary
@@ -1,4 +1,9 @@
1
1
  class Fluent::DeriveOutput < Fluent::Output
2
+ # Define `log` method for v0.10.42 or earlier
3
+ unless method_defined?(:log)
4
+ define_method("log") { $log }
5
+ end
6
+
2
7
  Fluent::Plugin.register_output('derive', self)
3
8
 
4
9
  KEY_MAX_NUM = 20
@@ -115,8 +120,8 @@ class Fluent::DeriveOutput < Fluent::Output
115
120
 
116
121
  chain.next
117
122
  rescue => e
118
- $log.warn e.message
119
- $log.warn e.backtrace.join(', ')
123
+ log.warn e.message
124
+ log.warn e.backtrace.join(', ')
120
125
  end
121
126
 
122
127
  # @return [Array] time, value
@@ -147,7 +152,7 @@ class Fluent::DeriveOutput < Fluent::Output
147
152
 
148
153
  def calc_rate(tag, key, cur_value, prev_value, cur_time, prev_time, adjustment = nil)
149
154
  if cur_time - prev_time <= 0
150
- $log.warn "Could not calculate the rate. multiple input less than one second or minus delta of seconds on tag=#{tag}, key=#{key}"
155
+ log.warn "Could not calculate the rate. multiple input less than one second or minus delta of seconds on tag=#{tag}, key=#{key}"
151
156
  return nil
152
157
  end
153
158
  rate = (cur_value - prev_value)/(cur_time - prev_time)
@@ -284,6 +284,42 @@ describe Fluent::DeriveOutput do
284
284
 
285
285
 
286
286
  end
287
+ end
288
+
289
+ describe 'test log' do
290
+ let(:log) { driver.instance.log }
291
+ let(:base_config) { %[
292
+ tag rate
293
+ key1 foo
294
+ ] }
295
+
296
+ def capture_log(log)
297
+ tmp = log.instance_variable_get(:@out)
298
+ out = StringIO.new
299
+ log.instance_variable_set(:@out, out)
300
+ yield log
301
+ return out.string
302
+ ensure
303
+ # Set back original instance to @out
304
+ log.instance_variable_set(:@out, tmp)
305
+ end
306
+
307
+ if Fluent::VERSION >= "0.10.43"
308
+ context "log_level info" do
309
+ let(:config) { base_config + %[log_level info] }
310
+
311
+ it "should not contain debug level" do
312
+ capture_log(log) {|log| log.debug "foobar" }.should == ""
313
+ end
314
+ end
315
+ end
287
316
 
317
+ context "log" do
318
+ let(:config) { base_config }
319
+ it "should work" do
320
+ capture_log(log) {|log| log.info "foobar" }.should include("foobar")
321
+ end
322
+ end
288
323
  end
324
+
289
325
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fluent-plugin-derive
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Nobuhiro Nikushi
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-12-23 00:00:00.000000000 Z
11
+ date: 2014-02-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: fluentd
@@ -62,7 +62,9 @@ files:
62
62
  - .gitignore
63
63
  - .rspec
64
64
  - .travis.yml
65
+ - CHANGELOG.md
65
66
  - Gemfile
67
+ - Gemfile.fluentd.lt.0.10.43
66
68
  - LICENSE.txt
67
69
  - README.md
68
70
  - Rakefile
@@ -91,7 +93,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
91
93
  version: '0'
92
94
  requirements: []
93
95
  rubyforge_project:
94
- rubygems_version: 2.1.10
96
+ rubygems_version: 2.0.14
95
97
  signing_key:
96
98
  specification_version: 4
97
99
  summary: fluentd plugin to derive rate