fluent-plugin-multi-format-parser 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 +4 -4
- data/VERSION +1 -1
- data/lib/fluent/plugin/parser_multi_format.rb +77 -33
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e03e39eca4a755d270f2f4e5d6f7122b9a53143d
|
4
|
+
data.tar.gz: 56e44dbaf28967bd180a9e391fce9cb52745f29c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e6aa259c436b56234a1071e080a022ae7704a766f04fe079168e9084409c2c5a4e6b3f67dea1c72c93e0517606f246ff1b739dec63d423218860ac6224812e04
|
7
|
+
data.tar.gz: fbcb92363e90e4af642e80572809eb4c2703abeda0c4465b2f6b8854cc3263aa900944ac84f37605e86f3d5390f5962569f8f45b52f737fdc48a05eb1acd58c8
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.0.
|
1
|
+
0.0.2
|
@@ -2,52 +2,96 @@ require 'fluent/parser'
|
|
2
2
|
|
3
3
|
module Fluent
|
4
4
|
class TextParser
|
5
|
-
|
6
|
-
|
5
|
+
if defined?(::Fluent::Parser)
|
6
|
+
class MultiFormatParser < Parser
|
7
|
+
Plugin.register_parser('multi_format', self)
|
7
8
|
|
8
|
-
|
9
|
-
|
9
|
+
def initialize
|
10
|
+
super
|
10
11
|
|
11
|
-
|
12
|
-
|
12
|
+
@parsers = []
|
13
|
+
end
|
13
14
|
|
14
|
-
|
15
|
-
|
15
|
+
def configure(conf)
|
16
|
+
super
|
16
17
|
|
17
|
-
|
18
|
-
|
18
|
+
conf.elements.each { |e|
|
19
|
+
next unless ['pattern', 'format'].include?(e.name)
|
19
20
|
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
21
|
+
parser = Plugin.new_parser(e['format'])
|
22
|
+
parser.configure(e)
|
23
|
+
@parsers << parser
|
24
|
+
}
|
25
|
+
end
|
25
26
|
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
if block_given?
|
27
|
+
def parse(text)
|
28
|
+
@parsers.each { |parser|
|
29
|
+
begin
|
30
|
+
parser.parse(text) { |time, record|
|
31
|
+
if time && record
|
32
32
|
yield time, record
|
33
33
|
return
|
34
|
-
else
|
35
|
-
return time, record
|
36
34
|
end
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
}
|
35
|
+
}
|
36
|
+
rescue # ignore parser error
|
37
|
+
end
|
38
|
+
}
|
42
39
|
|
43
|
-
if block_given?
|
44
40
|
yield nil, nil
|
45
|
-
else
|
46
|
-
return nil, nil
|
47
41
|
end
|
48
42
|
end
|
49
|
-
|
43
|
+
else # support old API. Will be removed.
|
44
|
+
class MultiFormatParser
|
45
|
+
include Configurable
|
46
|
+
|
47
|
+
def initialize
|
48
|
+
super
|
49
|
+
|
50
|
+
@parsers = []
|
51
|
+
end
|
52
|
+
|
53
|
+
def configure(conf)
|
54
|
+
super
|
55
|
+
|
56
|
+
conf.elements.each { |e|
|
57
|
+
next unless ['pattern', 'format'].include?(e.name)
|
50
58
|
|
51
|
-
|
59
|
+
parser = TextParser.new
|
60
|
+
parser.configure(e)
|
61
|
+
@parsers << parser.parser
|
62
|
+
}
|
63
|
+
end
|
64
|
+
|
65
|
+
def parse(text)
|
66
|
+
@parsers.each { |parser|
|
67
|
+
begin
|
68
|
+
parser.call(text) { |time, record|
|
69
|
+
if time && record
|
70
|
+
if block_given?
|
71
|
+
yield time, record
|
72
|
+
return
|
73
|
+
else
|
74
|
+
return time, record
|
75
|
+
end
|
76
|
+
end
|
77
|
+
}
|
78
|
+
rescue # ignore parser error
|
79
|
+
end
|
80
|
+
}
|
81
|
+
|
82
|
+
if block_given?
|
83
|
+
yield nil, nil
|
84
|
+
else
|
85
|
+
return nil, nil
|
86
|
+
end
|
87
|
+
end
|
88
|
+
|
89
|
+
def call(*a, &b)
|
90
|
+
parse(*a, &b)
|
91
|
+
end
|
92
|
+
end
|
93
|
+
|
94
|
+
register_template('multi_format', Proc.new { MultiFormatParser.new })
|
95
|
+
end
|
52
96
|
end
|
53
97
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: fluent-plugin-multi-format-parser
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Masahiro Nakagawa
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-
|
11
|
+
date: 2014-12-18 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: fluentd
|