fluent-plugin-tail_path 0.0.3 → 0.1.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 7035a9557c7fb34608badc84b8d937c0627f60df
4
- data.tar.gz: e16fd13e7436ac50fe1914ca71861e05ee996961
3
+ metadata.gz: 6c83607c70652fd3de4fbf8b05a283ce1c2dc9b0
4
+ data.tar.gz: a4c0ce8ca8fbf9a19bfb2af4e7cc10484a75770a
5
5
  SHA512:
6
- metadata.gz: 656da51399cfd849f7cf66292456ddac9a3ea7d218a8641ca64b88ba679df359b33fd0b29612ca5bd03094e115c224f536af6c95ffcec21d2776891748cd6376
7
- data.tar.gz: 0273cb6aa4283e046dedffd45dff24fd5a4f095f328fb04f3f2caed28ebcc4237d235349262d30eb48eaef9479cab226c6fb350b2a8e3439b1146109f44b03a6
6
+ metadata.gz: 65f3b4ff5fc2cd1852ffce114dba032d46301c584a27a30b1a9c6dec5cca250d061eaf17d4cd5be1546cb8c25aed42cd742bcf3b8b00b5c785e29f2bec6b402c
7
+ data.tar.gz: c735b9eb28f252b75f814ba063e7143c66804a2403ecd951bb5baea025eee773b32c0a9220bf67d089585e07d9ec74a18c2066ebf01a881e0c936e53f0e373d3
@@ -1,7 +1,11 @@
1
1
  rvm:
2
2
  - 1.9.3
3
- - 2.0.0
4
- - 2.1.*
3
+ - 2.0
4
+ - 2.1
5
+ - 2.2
6
+ - 2.3.0
7
+ before_install:
8
+ - gem update bundler
5
9
  gemfile:
6
10
  - Gemfile
7
- - "Gemfile.fluentd.lt.0.10.50"
11
+ - Gemfile.fluentd.v10
@@ -1,3 +1,13 @@
1
+ ## 0.1.0 (2016/04/10)
2
+
3
+ Fixes:
4
+
5
+ * Fix for multiline format for >= v0.12
6
+
7
+ Changes:
8
+
9
+ * Drop supports for < v0.10.58 instead
10
+
1
11
  ## 0.0.3 (2015/02/17)
2
12
 
3
13
  Fixes:
@@ -1,4 +1,4 @@
1
1
  source "http://rubygems.org"
2
2
 
3
3
  gemspec
4
- gem 'fluentd', '0.10.49'
4
+ gem 'fluentd', '~> v0.10.0'
@@ -0,0 +1,25 @@
1
+ # /tmp/application.log
2
+ # ==firstline
3
+ # foo
4
+ # ==firstline
5
+ # bar
6
+ # ==firstline
7
+ # baz
8
+
9
+ <source>
10
+ type tail_path
11
+ format multiline
12
+ format_firstline /^==firstline/
13
+ format1 /^(?<message>.*)/
14
+ path /tmp/application.log
15
+ refresh_interval 5
16
+ # pos_file /tmp/application.pos
17
+ read_from_head true
18
+ tag raw.test
19
+ path_key path
20
+ </source>
21
+
22
+ <match raw.**>
23
+ type stdout
24
+ log_level trace
25
+ </match>
@@ -1,15 +1,15 @@
1
1
  <source>
2
2
  type tail_path
3
3
  format none
4
- path /var/log/fluentd_test.log
5
- pos_file /var/log/fluentd_test.pos
6
- tag test
4
+ path /tmp/application.log
5
+ # pos_file /tmp/application.pos
7
6
  rotate_wait 5
8
7
  read_from_head true
9
8
  refresh_interval 60
10
9
  path_key path
10
+ tag raw.test
11
11
  </source>
12
12
 
13
- <match test>
13
+ <match raw.**>
14
14
  type stdout
15
15
  </match>
@@ -3,7 +3,7 @@ $:.push File.expand_path("../lib", __FILE__)
3
3
 
4
4
  Gem::Specification.new do |s|
5
5
  s.name = "fluent-plugin-tail_path"
6
- s.version = "0.0.3"
6
+ s.version = "0.1.0"
7
7
  s.authors = ["szhem", "Naotoshi Seo"]
8
8
  s.email = ["sonots@gmail.com"]
9
9
  s.homepage = "https://github.com/sonots/fluent-plugin-tail_path"
@@ -15,8 +15,7 @@ Gem::Specification.new do |s|
15
15
  s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
16
16
  s.require_paths = ["lib"]
17
17
 
18
- s.add_runtime_dependency "fluentd", ">= 0.10.45"
18
+ s.add_runtime_dependency "fluentd", ">= 0.10.58"
19
19
  s.add_development_dependency "rake"
20
- s.add_development_dependency "pry"
21
- s.add_development_dependency "pry-nav"
20
+ s.add_development_dependency "test-unit"
22
21
  end
@@ -1,83 +1,43 @@
1
1
  require 'fluent/plugin/in_tail'
2
2
 
3
3
  class Fluent::NewTailPathInput < Fluent::NewTailInput
4
- Fluent::Plugin.register_input('tail_path', self)
5
-
6
- config_param :path_key, :string, :default => nil
4
+ class RouterWrap
5
+ attr_accessor :tail_watcher
7
6
 
8
- def configure(conf)
9
- super
10
- end
11
-
12
- if method_defined?(:parse_line) # fluentd < 0.10.50
13
-
14
- # Override to add path field
15
- def convert_line_to_event(line, es, tail_watcher)
16
- begin
17
- line.chomp! # remove \n
18
- time, record = parse_line(line)
19
- if time && record
20
- record[@path_key] ||= tail_watcher.path unless @path_key.nil? # custom
21
- es.add(time, record)
22
- else
23
- log.warn "pattern not match: #{line.inspect}"
24
- end
25
- rescue => e
26
- log.warn line.dump, :error => e.to_s
27
- log.debug_backtrace(e)
28
- end
7
+ def initialize(router, path_key)
8
+ @router = router
9
+ @path_key = path_key
10
+ @tail_watcher = nil
29
11
  end
30
12
 
31
- else # fluentd >= 0.10.50
13
+ def emit(tag, time, record)
14
+ record[@path_key] = @tail_watcher.path unless @path_key.nil?
15
+ @router.emit(tag, time, record)
16
+ end
32
17
 
33
- # Override to add path field
34
- def convert_line_to_event(line, es, tail_watcher)
35
- begin
36
- line.chomp! # remove \n
37
- @parser.parse(line) { |time, record|
38
- if time && record
39
- record[@path_key] ||= tail_watcher.path unless @path_key.nil? # custom
40
- es.add(time, record)
41
- else
42
- log.warn "pattern not match: #{line.inspect}"
43
- end
44
- }
45
- rescue => e
46
- log.warn line.dump, :error => e.to_s
47
- log.debug_backtrace(e)
48
- end
18
+ def emit_array(tag, array)
19
+ @router.emit_array(tag, array)
49
20
  end
50
21
 
22
+ def emit_stream(tag, es)
23
+ es.each {|time,record|
24
+ record[@path_key] = @tail_watcher.path unless @path_key.nil?
25
+ }
26
+ @router.emit_stream(tag, es)
27
+ end
51
28
  end
52
29
 
53
- # Override to pass tail_watcher to convert_line_to_event
54
- def parse_singleline(lines, tail_watcher)
55
- es = ::Fluent::MultiEventStream.new
56
- lines.each { |line|
57
- convert_line_to_event(line, es, tail_watcher)
58
- }
59
- es
30
+ Fluent::Plugin.register_input('tail_path', self)
31
+
32
+ config_param :path_key, :string, :default => nil
33
+
34
+ def configure(conf)
35
+ super
36
+ @router = RouterWrap.new(@router, @path_key)
60
37
  end
61
38
 
62
- # Override to pass tail_watcher to convert_line_to_event
63
- def parse_multilines(lines, tail_watcher)
64
- lb = tail_watcher.line_buffer
65
- es = ::Fluent::MultiEventStream.new
66
- lines.each { |line|
67
- if @parser.parser.firstline?(line)
68
- if lb
69
- convert_line_to_event(lb, es, tail_watcher)
70
- end
71
- lb = line
72
- else
73
- if lb.nil?
74
- log.warn "got incomplete line before first line from #{tail_watcher.path}: #{lb.inspect}"
75
- else
76
- lb << line
77
- end
78
- end
79
- }
80
- tail_watcher.line_buffer = lb
81
- es
39
+ def receive_lines(lines, tail_watcher)
40
+ @router.tail_watcher = tail_watcher
41
+ super
82
42
  end
83
43
  end
@@ -12,7 +12,6 @@ require 'test/unit'
12
12
  $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
13
13
  $LOAD_PATH.unshift(File.dirname(__FILE__))
14
14
  require 'fluent/test'
15
- require 'fluent/plugin/in_tail_path'
16
15
 
17
16
  class Test::Unit::TestCase
18
17
  end
@@ -0,0 +1,8 @@
1
+ require_relative 'helper'
2
+ require 'fluent/plugin/in_tail_path'
3
+
4
+ class TailPathInputTest < Test::Unit::TestCase
5
+ def setup
6
+ Fluent::Test.setup
7
+ end
8
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fluent-plugin-tail_path
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3
4
+ version: 0.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - szhem
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2015-02-17 00:00:00.000000000 Z
12
+ date: 2016-04-09 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: fluentd
@@ -17,14 +17,14 @@ dependencies:
17
17
  requirements:
18
18
  - - ">="
19
19
  - !ruby/object:Gem::Version
20
- version: 0.10.45
20
+ version: 0.10.58
21
21
  type: :runtime
22
22
  prerelease: false
23
23
  version_requirements: !ruby/object:Gem::Requirement
24
24
  requirements:
25
25
  - - ">="
26
26
  - !ruby/object:Gem::Version
27
- version: 0.10.45
27
+ version: 0.10.58
28
28
  - !ruby/object:Gem::Dependency
29
29
  name: rake
30
30
  requirement: !ruby/object:Gem::Requirement
@@ -40,21 +40,7 @@ dependencies:
40
40
  - !ruby/object:Gem::Version
41
41
  version: '0'
42
42
  - !ruby/object:Gem::Dependency
43
- name: pry
44
- requirement: !ruby/object:Gem::Requirement
45
- requirements:
46
- - - ">="
47
- - !ruby/object:Gem::Version
48
- version: '0'
49
- type: :development
50
- prerelease: false
51
- version_requirements: !ruby/object:Gem::Requirement
52
- requirements:
53
- - - ">="
54
- - !ruby/object:Gem::Version
55
- version: '0'
56
- - !ruby/object:Gem::Dependency
57
- name: pry-nav
43
+ name: test-unit
58
44
  requirement: !ruby/object:Gem::Requirement
59
45
  requirements:
60
46
  - - ">="
@@ -78,15 +64,16 @@ files:
78
64
  - ".travis.yml"
79
65
  - CHANGELOG.md
80
66
  - Gemfile
81
- - Gemfile.fluentd.lt.0.10.50
67
+ - Gemfile.fluentd.v10
82
68
  - LICENSE
83
69
  - README.md
84
70
  - Rakefile
85
- - example.conf
71
+ - example/multiline.conf
72
+ - example/singleline.conf
86
73
  - fluent-plugin-tail_path.gemspec
87
74
  - lib/fluent/plugin/in_tail_path.rb
88
75
  - test/helper.rb
89
- - test/plugin/in_tail_path.rb
76
+ - test/in_tail_path.rb
90
77
  homepage: https://github.com/sonots/fluent-plugin-tail_path
91
78
  licenses: []
92
79
  metadata: {}
@@ -106,10 +93,10 @@ required_rubygems_version: !ruby/object:Gem::Requirement
106
93
  version: '0'
107
94
  requirements: []
108
95
  rubyforge_project:
109
- rubygems_version: 2.2.2
96
+ rubygems_version: 2.5.1
110
97
  signing_key:
111
98
  specification_version: 4
112
99
  summary: Fluentd in_tail extension to add `path` field
113
100
  test_files:
114
101
  - test/helper.rb
115
- - test/plugin/in_tail_path.rb
102
+ - test/in_tail_path.rb
@@ -1,52 +0,0 @@
1
- require_relative '../helper'
2
-
3
- class TailPathInputTest < Test::Unit::TestCase
4
- def setup
5
- Fluent::Test.setup
6
- FileUtils.rm_rf(TMP_DIR)
7
- FileUtils.mkdir_p(TMP_DIR)
8
- end
9
-
10
- TMP_DIR = File.dirname(__FILE__) + "/../tmp/tail#{ENV['TEST_ENV_NUMBER']}"
11
-
12
- COMMON_CONFIG = %[
13
- path #{TMP_DIR}/tail.txt
14
- tag t1
15
- rotate_wait 2s
16
- pos_file #{TMP_DIR}/tail.pos
17
- ]
18
- SINGLE_LINE_CONFIG = %[
19
- format /(?<message>.*)/
20
- ]
21
-
22
- def create_driver(conf = SINGLE_LINE_CONFIG, use_common_conf = true)
23
- config = use_common_conf ? COMMON_CONFIG + conf : conf
24
- Fluent::Test::InputTestDriver.new(Fluent::NewTailPathInput).configure(config)
25
- end
26
-
27
- def test_path_key
28
- File.open("#{TMP_DIR}/tail.txt", "w") { |f| }
29
-
30
- d = create_driver(%[
31
- path #{TMP_DIR}/tail.txt
32
- tag t1
33
- format /(?<message>.*)/
34
- path_key foobar
35
- ], false)
36
-
37
- d.run do
38
- sleep 1
39
-
40
- File.open("#{TMP_DIR}/tail.txt", "a") {|f|
41
- f.puts "test1"
42
- f.puts "test2"
43
- }
44
- sleep 1
45
- end
46
-
47
- emits = d.emits
48
- assert_equal(true, emits.length > 0)
49
- assert_equal({"message"=>"test1", "foobar"=>"#{TMP_DIR}/tail.txt"}, emits[0][2])
50
- assert_equal({"message"=>"test2", "foobar"=>"#{TMP_DIR}/tail.txt"}, emits[1][2])
51
- end
52
- end