fluent-plugin-forest 0.2.0 → 0.2.1

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: 8de96a623bfa6608e043f68ca1dbd0549ed4d315
4
- data.tar.gz: e34249c2332e2520d75aba897b852045db5ce983
3
+ metadata.gz: e0a7d7f3b087e4e98b95b64c59cba05d0e7414ae
4
+ data.tar.gz: 0de19f3bffae6681c880ba68eed4189875c30ca7
5
5
  SHA512:
6
- metadata.gz: 64f32283a2f2cde11e07ce690ed810b492990ee9a48b7a18e91bb643b31140dec89991d9f924998ce0152505df703466adaf01d6bc8f2562c679ff20f7d4aa86
7
- data.tar.gz: 35aa6d7e0c3e8dd8df00387569d60a6a583a66511fb0bdaa9fea9d04bba75f9b2742450b39c367f9d0dab1d164083125e99a6144c49fa8cf6165265a15ef2e45
6
+ metadata.gz: d8058bf19db99b46c8af6c0f181fec8af939f6fb8785c99447c59aa87ae6abbc816f023c692ea2ccb2ab8fb215c3ce9cb89affd0bda9f35df9c595e36b9db9ef
7
+ data.tar.gz: 6e49a2ad4a71002ef3eaa67db20782fda87d0271b9ef2fda4eccabb89b4d986004cba88879dd27e7e878657d7ab3256f8242fd5f35f0bc811d9f435672e93788
data/README.md CHANGED
@@ -12,6 +12,8 @@ This plugin helps you if you are writing very long configurations by copy&paste
12
12
  Other supported placeholders:
13
13
  * \_\_HOSTNAME\_\_ (or ${hostname})
14
14
  * replaced with string specified by 'hostname' configuration value, or (default) result of 'hostname' command
15
+ * \_\_ESCAPED\_TAG\_\_ (or ${escaped\_tag})
16
+ * replaced with escaped tag. Escaped tag is replaced '.' with a character specified by 'escape\_tag\_separator' (default: '\_')
15
17
 
16
18
  You SHOULD NOT use ForestOutput for tags increasing infinitly.
17
19
 
@@ -1,12 +1,13 @@
1
1
  # -*- encoding: utf-8 -*-
2
2
  Gem::Specification.new do |gem|
3
3
  gem.name = "fluent-plugin-forest"
4
- gem.version = "0.2.0"
4
+ gem.version = "0.2.1"
5
5
  gem.authors = ["TAGOMORI Satoshi"]
6
6
  gem.email = ["tagomoris@gmail.com"]
7
7
  gem.description = %q{create sub-plugin dynamically per tags, with template configuration and parameters}
8
8
  gem.summary = %q{plugin to create output plugin instances per tags dynamically}
9
9
  gem.homepage = "https://github.com/tagomoris/fluent-plugin-forest"
10
+ gem.license = "APLv2"
10
11
 
11
12
  gem.files = `git ls-files`.split($\)
12
13
  gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
@@ -5,6 +5,7 @@ class Fluent::ForestOutput < Fluent::MultiOutput
5
5
  config_param :remove_prefix, :string, :default => nil
6
6
  config_param :add_prefix, :string, :default => nil
7
7
  config_param :hostname, :string, :default => `hostname`.chomp
8
+ config_param :escape_tag_separator, :string, :default => '_'
8
9
 
9
10
  attr_reader :outputs
10
11
 
@@ -60,8 +61,10 @@ class Fluent::ForestOutput < Fluent::MultiOutput
60
61
  end
61
62
 
62
63
  def parameter(tag, e, name = 'instance', arg = '')
64
+ escaped_tag = tag.gsub('.', @escape_tag_separator)
63
65
  pairs = {}
64
66
  e.each do |k,v|
67
+ v = v.gsub('__ESCAPED_TAG__', escaped_tag).gsub('${escaped_tag}', escaped_tag)
65
68
  pairs[k] = v.gsub('__TAG__', tag).gsub('${tag}', tag).gsub('__HOSTNAME__', @hostname).gsub('${hostname}', @hostname)
66
69
  end
67
70
  elements = e.elements.map do |child|
@@ -231,6 +231,60 @@ subtype hoge
231
231
  assert_equal 'dupdup', conf.elements[6]['key']
232
232
  end
233
233
 
234
+ def test_spec_replace_tag_separator
235
+ d = create_driver %[
236
+ subtype hoge
237
+ <template>
238
+ keyx xxxxxx
239
+ keyy yyyyyy.__ESCAPED_TAG__
240
+ </template>
241
+ <case xx.*>
242
+ keyz zzzzzz.__ESCAPED_TAG__
243
+ alt_key a
244
+ </case>
245
+ <case xx.**>
246
+ keyz zzzzzz.${escaped_tag}
247
+ alt_key b
248
+ </case>
249
+ ]
250
+
251
+ conf = d.instance.spec('xx.1')
252
+ assert_equal 'xxxxxx', conf['keyx']
253
+ assert_equal 'yyyyyy.xx_1', conf['keyy']
254
+ assert_equal 'zzzzzz.xx_1', conf['keyz']
255
+ assert_equal 'a', conf['alt_key']
256
+
257
+ conf = d.instance.spec('xx.1.2')
258
+ assert_equal 'xxxxxx', conf['keyx']
259
+ assert_equal 'yyyyyy.xx_1_2', conf['keyy']
260
+ assert_equal 'zzzzzz.xx_1_2', conf['keyz']
261
+ assert_equal 'b', conf['alt_key']
262
+ end
263
+
264
+ def test_spec_replace_tag_separator_with_specified_char
265
+ d = create_driver %[
266
+ subtype hoge
267
+ escape_tag_separator +
268
+ <template>
269
+ keyx xxxxxx
270
+ keyy yyyyyy.__ESCAPED_TAG__
271
+ </template>
272
+ <case xx.**>
273
+ keyz zzzzzz.${escaped_tag}
274
+ </case>
275
+ ]
276
+
277
+ conf = d.instance.spec('xx.1')
278
+ assert_equal 'xxxxxx', conf['keyx']
279
+ assert_equal 'yyyyyy.xx+1', conf['keyy']
280
+ assert_equal 'zzzzzz.xx+1', conf['keyz']
281
+
282
+ conf = d.instance.spec('xx.1.2')
283
+ assert_equal 'xxxxxx', conf['keyx']
284
+ assert_equal 'yyyyyy.xx+1+2', conf['keyy']
285
+ assert_equal 'zzzzzz.xx+1+2', conf['keyz']
286
+ end
287
+
234
288
  def test_spec_hostname
235
289
  d = create_driver %[
236
290
  subtype hoge
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fluent-plugin-forest
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - TAGOMORI Satoshi
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-08-13 00:00:00.000000000 Z
11
+ date: 2013-09-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake
@@ -58,7 +58,8 @@ files:
58
58
  - test/plugin/test_out_forest.rb
59
59
  - test/plugin/test_out_forest_test.rb
60
60
  homepage: https://github.com/tagomoris/fluent-plugin-forest
61
- licenses: []
61
+ licenses:
62
+ - APLv2
62
63
  metadata: {}
63
64
  post_install_message:
64
65
  rdoc_options: []
@@ -76,7 +77,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
76
77
  version: '0'
77
78
  requirements: []
78
79
  rubyforge_project:
79
- rubygems_version: 2.0.2
80
+ rubygems_version: 2.0.3
80
81
  signing_key:
81
82
  specification_version: 4
82
83
  summary: plugin to create output plugin instances per tags dynamically