fluent-plugin-rewrite 0.0.4 → 0.0.5
Sign up to get free protection for your applications and to get access to all the features.
@@ -58,7 +58,7 @@ module Fluent
|
|
58
58
|
if @remove_prefix and
|
59
59
|
((tag.start_with?(@removed_prefix_string) && tag.length > @removed_length) ||
|
60
60
|
tag == @remove_prefix)
|
61
|
-
tag = tag[@removed_length..-1]
|
61
|
+
tag = tag[@removed_length..-1] || ''
|
62
62
|
end
|
63
63
|
|
64
64
|
if @add_prefix
|
@@ -94,9 +94,9 @@ module Fluent
|
|
94
94
|
|
95
95
|
if rule["append_to_tag"]
|
96
96
|
if rule["tag"]
|
97
|
-
tag << "
|
97
|
+
tag << (tag == "" ? "" : ".") << "#{rule["tag"]}"
|
98
98
|
else
|
99
|
-
matched.captures.each { |m| tag << "
|
99
|
+
matched.captures.each { |m| tag << (tag == "" ? "" : ".") << "#{m}" }
|
100
100
|
end
|
101
101
|
end
|
102
102
|
|
@@ -158,6 +158,37 @@ class RewriteOutputTest < Test::Unit::TestCase
|
|
158
158
|
[ "test", { "is_logged_in" => "0" } ],
|
159
159
|
d3.instance.rewrite("test", { "is_logged_in" => "0" })
|
160
160
|
)
|
161
|
+
|
162
|
+
d4 = create_driver(%[
|
163
|
+
remove_prefix test
|
164
|
+
|
165
|
+
<rule>
|
166
|
+
key path
|
167
|
+
pattern ^\/(users|entries)
|
168
|
+
append_to_tag true
|
169
|
+
</rule>
|
170
|
+
])
|
171
|
+
|
172
|
+
assert_equal(
|
173
|
+
[ "users", { "path" => "/users/antipop" } ],
|
174
|
+
d4.instance.rewrite("test", { "path" => "/users/antipop" })
|
175
|
+
)
|
176
|
+
|
177
|
+
d5 = create_driver(%[
|
178
|
+
remove_prefix test
|
179
|
+
|
180
|
+
<rule>
|
181
|
+
key is_logged_in
|
182
|
+
pattern 1
|
183
|
+
append_to_tag true
|
184
|
+
tag user
|
185
|
+
</rule>
|
186
|
+
])
|
187
|
+
|
188
|
+
assert_equal(
|
189
|
+
[ "user", { "is_logged_in" => "1" } ],
|
190
|
+
d5.instance.rewrite("test", { "is_logged_in" => "1" })
|
191
|
+
)
|
161
192
|
end
|
162
193
|
|
163
194
|
def test_last
|