fluent-plugin-map 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- data/fluent-plugin-map.gemspec +4 -6
- data/lib/fluent/plugin/out_map.rb +22 -13
- data/test/plugin/test_out_map.rb +32 -0
- metadata +11 -11
data/fluent-plugin-map.gemspec
CHANGED
@@ -3,10 +3,10 @@ $:.push File.expand_path("../lib", __FILE__)
|
|
3
3
|
|
4
4
|
Gem::Specification.new do |s|
|
5
5
|
s.name = "fluent-plugin-map"
|
6
|
-
s.version = "0.0.
|
6
|
+
s.version = "0.0.2"
|
7
7
|
s.authors = ["Kohei Tomita"]
|
8
8
|
s.email = ["tommy.fmale@gmail.com"]
|
9
|
-
s.homepage = ""
|
9
|
+
s.homepage = "https://github.com/tomity/fluent-plugin-map"
|
10
10
|
s.summary = %q{fluent-plugin-map is the non-buffered plugin that can convert an event log to different event log(s). }
|
11
11
|
s.description = %q{fluent-plugin-map is the non-buffered plugin that can convert an event log to different event log(s). }
|
12
12
|
|
@@ -17,8 +17,6 @@ Gem::Specification.new do |s|
|
|
17
17
|
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
18
18
|
s.require_paths = ["lib"]
|
19
19
|
|
20
|
-
|
21
|
-
s.add_development_dependency "
|
22
|
-
s.add_development_dependency "fluentd"
|
23
|
-
# s.add_runtime_dependency "rest-client"
|
20
|
+
s.add_development_dependency "rake", "~> 0.9.2.2"
|
21
|
+
s.add_development_dependency "fluentd", "~> 0.10.24"
|
24
22
|
end
|
@@ -12,21 +12,30 @@ module Fluent
|
|
12
12
|
end
|
13
13
|
|
14
14
|
def emit(tag, es, chain)
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
15
|
+
begin
|
16
|
+
tuples = []
|
17
|
+
es.each {|time, record|
|
18
|
+
new_tuple = eval(@map)
|
19
|
+
if @multi
|
20
|
+
tuples.concat new_tuple
|
21
|
+
else
|
22
|
+
tuples << new_tuple
|
23
|
+
end
|
24
|
+
}
|
25
|
+
tuples.each do |tag, time, record|
|
26
|
+
if time == nil or record == nil
|
27
|
+
raise SyntaxError.new
|
28
|
+
end
|
29
|
+
$log.trace { [tag, time, record].inspect }
|
30
|
+
Fluent::Engine::emit(tag, time, record)
|
22
31
|
end
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
32
|
+
chain.next
|
33
|
+
tuples
|
34
|
+
rescue SyntaxError => e
|
35
|
+
chain.next
|
36
|
+
$log.error "Select_if command is syntax error: #{@map}"
|
37
|
+
e #for test
|
27
38
|
end
|
28
|
-
chain.next
|
29
|
-
tuples
|
30
39
|
end
|
31
40
|
end
|
32
41
|
end
|
data/test/plugin/test_out_map.rb
CHANGED
@@ -47,4 +47,36 @@ class MapOutputTest < Test::Unit::TestCase
|
|
47
47
|
assert_equal ["tag1", time.to_i, record], emits[0]
|
48
48
|
assert_equal ["tag2", time.to_i, record], emits[1]
|
49
49
|
end
|
50
|
+
|
51
|
+
def test_syntax_error
|
52
|
+
tag = "tag"
|
53
|
+
time = Time.local(2012, 10, 10, 10, 10, 0)
|
54
|
+
record = {'code' => '300'}
|
55
|
+
|
56
|
+
#map is syntax error
|
57
|
+
syntax_error_config = %[
|
58
|
+
map tag.
|
59
|
+
]
|
60
|
+
d1 = create_driver(syntax_error_config, tag)
|
61
|
+
es = Fluent::OneEventStream.new(time.to_i, record)
|
62
|
+
chain = Fluent::Test::TestOutputChain.new
|
63
|
+
e = d1.instance.emit(tag, es, chain)
|
64
|
+
assert e.kind_of?(SyntaxError)
|
65
|
+
end
|
66
|
+
|
67
|
+
def test_syntax_error2
|
68
|
+
tag = "tag"
|
69
|
+
time = Time.local(2012, 10, 10, 10, 10, 0)
|
70
|
+
record = {'code' => '300'}
|
71
|
+
|
72
|
+
#map output lligal format
|
73
|
+
syntax_error_config = %[
|
74
|
+
map tag
|
75
|
+
]
|
76
|
+
d1 = create_driver(syntax_error_config, tag)
|
77
|
+
es = Fluent::OneEventStream.new(time.to_i, record)
|
78
|
+
chain = Fluent::Test::TestOutputChain.new
|
79
|
+
e = d1.instance.emit(tag, es, chain)
|
80
|
+
assert e.kind_of?(SyntaxError)
|
81
|
+
end
|
50
82
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: fluent-plugin-map
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,30 +9,30 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-07-
|
12
|
+
date: 2012-07-13 00:00:00.000000000Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rake
|
16
|
-
requirement: &
|
16
|
+
requirement: &70329973241780 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
|
-
- -
|
19
|
+
- - ~>
|
20
20
|
- !ruby/object:Gem::Version
|
21
|
-
version:
|
21
|
+
version: 0.9.2.2
|
22
22
|
type: :development
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
24
|
+
version_requirements: *70329973241780
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: fluentd
|
27
|
-
requirement: &
|
27
|
+
requirement: &70329973241200 !ruby/object:Gem::Requirement
|
28
28
|
none: false
|
29
29
|
requirements:
|
30
|
-
- -
|
30
|
+
- - ~>
|
31
31
|
- !ruby/object:Gem::Version
|
32
|
-
version:
|
32
|
+
version: 0.10.24
|
33
33
|
type: :development
|
34
34
|
prerelease: false
|
35
|
-
version_requirements: *
|
35
|
+
version_requirements: *70329973241200
|
36
36
|
description: ! 'fluent-plugin-map is the non-buffered plugin that can convert an event
|
37
37
|
log to different event log(s). '
|
38
38
|
email:
|
@@ -49,7 +49,7 @@ files:
|
|
49
49
|
- lib/fluent/plugin/out_map.rb
|
50
50
|
- test/helper.rb
|
51
51
|
- test/plugin/test_out_map.rb
|
52
|
-
homepage:
|
52
|
+
homepage: https://github.com/tomity/fluent-plugin-map
|
53
53
|
licenses: []
|
54
54
|
post_install_message:
|
55
55
|
rdoc_options: []
|