fluent-plugin-notifier 0.2.3 → 0.2.4

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
  SHA1:
3
- metadata.gz: 819e0e5c533b1b364de48803a65dd2b576cb754f
4
- data.tar.gz: fd4e2261616683930ba6d90b7261bbc502ff85ae
3
+ metadata.gz: 51bbc47ed97c53bc01c97c23c0e207f34c25b082
4
+ data.tar.gz: 86e03386b945389577efdde8cddb313f0fddc741
5
5
  SHA512:
6
- metadata.gz: 4c4a68ea9a7028d285eea418503759b47dacc959ef3f96187ec60eb586817d51de0e4446766d48c2edfeb5f41cea6576c41ac4c3951d0add4efde509a9230304
7
- data.tar.gz: 37e8b7d8d0cd28de54c6d0b66bf67ad0c73e049e6705490953146fc77f89aecc2fb3cf4f0c1277e41400edba489edd7b1b4e9ed00e6cbd4cab5054531d84dec7
6
+ metadata.gz: a61e5437151977331a9688057fe50bcbad4695584188bd7181550582108de45e2a03834355fb095a3aa04289bd6b6f8289fc2ce5021d4c6de95d0a008f5a24aa
7
+ data.tar.gz: 44cd882c4c4b9bca4ff6449c40d167be30695ac55cd5d4d7210376dcf198920dfd91cd73fc03881b7b314ad8fc4e3e88459b8a05182f2a1f5d8af65e7238c4be
@@ -1,7 +1,7 @@
1
1
  # -*- encoding: utf-8 -*-
2
2
  Gem::Specification.new do |gem|
3
3
  gem.name = "fluent-plugin-notifier"
4
- gem.version = "0.2.3"
4
+ gem.version = "0.2.4"
5
5
  gem.authors = ["TAGOMORI Satoshi"]
6
6
  gem.email = ["tagomoris@gmail.com"]
7
7
  gem.summary = %q{check matched messages and emit alert message}
@@ -14,6 +14,7 @@ Gem::Specification.new do |gem|
14
14
  gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
15
15
  gem.require_paths = ["lib"]
16
16
 
17
+ gem.add_development_dependency "test-unit"
17
18
  gem.add_development_dependency "rake"
18
19
  gem.add_runtime_dependency "fluentd"
19
20
  end
@@ -401,7 +401,7 @@ class Fluent::NotifierOutput < Fluent::Output
401
401
  end
402
402
  when :find
403
403
  str = record[key].to_s
404
- if @crit_regexp and @crit_regexp.match(str)
404
+ if match(@crit_regexp, str)
405
405
  {
406
406
  :hashkey => @pattern + "\t" + tag + "\t" + key,
407
407
  :match_def => self,
@@ -409,7 +409,7 @@ class Fluent::NotifierOutput < Fluent::Output
409
409
  'pattern' => @pattern, 'target_tag' => tag, 'target_key' => key, 'check_type' => 'string_find', 'level' => 'crit',
410
410
  'regexp' => @crit_regexp.inspect, 'value' => str, 'message_time' => Time.at(time).to_s
411
411
  }
412
- elsif @warn_regexp and @warn_regexp.match(str)
412
+ elsif match(@warn_regexp, str)
413
413
  {
414
414
  :hashkey => @pattern + "\t" + tag + "\t" + key,
415
415
  :match_def => self,
@@ -424,6 +424,20 @@ class Fluent::NotifierOutput < Fluent::Output
424
424
  raise ArgumentError, "unknown check type (maybe bug): #{@check}"
425
425
  end
426
426
  end
427
+
428
+ def match(regexp,string)
429
+ regexp && regexp.match(string)
430
+ rescue ArgumentError => e
431
+ raise e unless e.message.index("invalid byte sequence in") == 0
432
+ replaced_string = replace_invalid_byte(string)
433
+ regexp.match(replaced_string)
434
+ end
435
+
436
+ def replace_invalid_byte(string)
437
+ replace_options = { invalid: :replace, undef: :replace, replace: '?' }
438
+ temporal_encoding = (string.encoding == Encoding::UTF_8 ? Encoding::UTF_16BE : Encoding::UTF_8)
439
+ string.encode(temporal_encoding, string.encoding, replace_options).encode(string.encoding)
440
+ end
427
441
  end
428
442
 
429
443
  class State
@@ -1,6 +1,10 @@
1
1
  require 'helper'
2
2
 
3
3
  class NotifierOutputTest < Test::Unit::TestCase
4
+ def setup
5
+ Fluent::Test.setup
6
+ end
7
+
4
8
  CONFIG = %[
5
9
  type notifier
6
10
  input_tag_remove_prefix test
@@ -108,4 +112,14 @@ class NotifierOutputTest < Test::Unit::TestCase
108
112
  end
109
113
  assert_equal 0, d.emits.size
110
114
  end
115
+
116
+ def test_emit_invalid_byte
117
+ invalid_utf8 = "\xff".force_encoding('UTF-8')
118
+ d = create_driver
119
+ assert_nothing_raised {
120
+ d.run do
121
+ d.emit({'num1' => 60, 'message' => "foo bar WARNING #{invalid_utf8}", 'numfield' => '30', 'textfield' => 'TargetX'})
122
+ end
123
+ }
124
+ end
111
125
  end
metadata CHANGED
@@ -1,15 +1,29 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fluent-plugin-notifier
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.3
4
+ version: 0.2.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - TAGOMORI Satoshi
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-06-27 00:00:00.000000000 Z
11
+ date: 2015-11-24 00:00:00.000000000 Z
12
12
  dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: test-unit
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
13
27
  - !ruby/object:Gem::Dependency
14
28
  name: rake
15
29
  requirement: !ruby/object:Gem::Requirement
@@ -78,7 +92,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
78
92
  version: '0'
79
93
  requirements: []
80
94
  rubyforge_project:
81
- rubygems_version: 2.2.2
95
+ rubygems_version: 2.4.5
82
96
  signing_key:
83
97
  specification_version: 4
84
98
  summary: check matched messages and emit alert message
@@ -88,3 +102,4 @@ test_files:
88
102
  - test/plugin/test_out_notifier.rb
89
103
  - test/plugin/test_state.rb
90
104
  - test/plugin/test_test.rb
105
+ has_rdoc: