fluent-plugin-to_s 0.0.1
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 +7 -0
- data/.gitignore +40 -0
- data/Gemfile +4 -0
- data/LICENSE +0 -0
- data/README.md +31 -0
- data/Rakefile +10 -0
- data/fluent-plugin-to_s.gemspec +24 -0
- data/lib/fluent/plugin/out_to_s.rb +31 -0
- data/test/helper.rb +28 -0
- data/test/plugin/test_out_to_s.rb +37 -0
- metadata +97 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: b6bdd45ffe5380ff5b14b7366434c3127b3453c6
|
4
|
+
data.tar.gz: 79480a37e9a3c8d09fdffd8d109694d63cdd0e92
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 8a930c3dc9118b52efc0625fee8f31ec686e4576c6453cc28209ca46155fa8968749ba45377ae436b8b73c1ff143ff255febf5806ce72f41577412d001dbd229
|
7
|
+
data.tar.gz: f0faae3a700c11c32d83ed5971dd5186832d442b0e6af80ec02b248997daf3b3abe6ec41993c7b22841aa3889582858570dfa321d7caa4e91e3e5fd8d87b04a2
|
data/.gitignore
ADDED
@@ -0,0 +1,40 @@
|
|
1
|
+
# Created by https://www.gitignore.io
|
2
|
+
|
3
|
+
### Ruby ###
|
4
|
+
*.gem
|
5
|
+
*.rbc
|
6
|
+
*.lock
|
7
|
+
/.config
|
8
|
+
/coverage/
|
9
|
+
/InstalledFiles
|
10
|
+
/pkg/
|
11
|
+
/spec/reports/
|
12
|
+
/test/tmp/
|
13
|
+
/test/version_tmp/
|
14
|
+
/tmp/
|
15
|
+
|
16
|
+
## Specific to RubyMotion:
|
17
|
+
.dat*
|
18
|
+
.repl_history
|
19
|
+
build/
|
20
|
+
|
21
|
+
## Documentation cache and generated files:
|
22
|
+
/.yardoc/
|
23
|
+
/_yardoc/
|
24
|
+
/doc/
|
25
|
+
/rdoc/
|
26
|
+
|
27
|
+
## Environment normalisation:
|
28
|
+
/.bundle/
|
29
|
+
/vendor/bundle
|
30
|
+
/lib/bundler/man/
|
31
|
+
|
32
|
+
# for a library or gem, you might want to ignore these files since the code is
|
33
|
+
# intended to run in multiple environments; otherwise, check them in:
|
34
|
+
# Gemfile.lock
|
35
|
+
# .ruby-version
|
36
|
+
# .ruby-gemset
|
37
|
+
|
38
|
+
# unless supporting rvm < 1.11.0 or doing something fancy, ignore this:
|
39
|
+
.rvmrc
|
40
|
+
|
data/Gemfile
ADDED
data/LICENSE
ADDED
File without changes
|
data/README.md
ADDED
@@ -0,0 +1,31 @@
|
|
1
|
+
# fluent-plugin-to_s
|
2
|
+
|
3
|
+
Plugin that adds whole record to to_s field
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
```bash
|
8
|
+
gem install fluent-plugin-to_s
|
9
|
+
```
|
10
|
+
|
11
|
+
## Usage
|
12
|
+
|
13
|
+
```xml
|
14
|
+
<match test.**>
|
15
|
+
type to_s
|
16
|
+
tag_prefix string
|
17
|
+
field_name to_string
|
18
|
+
</match>
|
19
|
+
```
|
20
|
+
|
21
|
+
### following inputs are coming:
|
22
|
+
|
23
|
+
```
|
24
|
+
test.hoge {"data":"wef"}
|
25
|
+
```
|
26
|
+
|
27
|
+
### then output becomes as belows
|
28
|
+
|
29
|
+
```
|
30
|
+
string.test.hoge {"data":"wef", "to_string":"{\"data\":\"wef\"}"}
|
31
|
+
```
|
data/Rakefile
ADDED
@@ -0,0 +1,24 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
# require 'fluent/plugin/add/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "fluent-plugin-to_s"
|
8
|
+
spec.version = "0.0.1"
|
9
|
+
spec.authors = ["airtoxin"]
|
10
|
+
spec.email = ["airtoxin@icloud.com"]
|
11
|
+
spec.description = %q{Plugin that adds whole record to to_s field}
|
12
|
+
spec.summary = %q{Plugin that adds whole record to to_s field}
|
13
|
+
spec.homepage = "https://github.com/airtoxin/fluent-plugin-to_s"
|
14
|
+
spec.license = "MIT"
|
15
|
+
|
16
|
+
spec.files = `git ls-files`.split($/)
|
17
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
18
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
|
+
spec.require_paths = ["lib"]
|
20
|
+
|
21
|
+
spec.add_development_dependency "bundler", "~> 1.3"
|
22
|
+
spec.add_development_dependency "rake"
|
23
|
+
spec.add_runtime_dependency "fluentd"
|
24
|
+
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
class Fluent::ToSOutput < Fluent::Output
|
2
|
+
Fluent::Plugin.register_output('to_s', self)
|
3
|
+
|
4
|
+
config_param :tag_prefix, :string, :default => ''
|
5
|
+
config_param :field_name, :string, :default => 'to_s'
|
6
|
+
|
7
|
+
def configure(conf)
|
8
|
+
super
|
9
|
+
|
10
|
+
@prefix = "#{@tag_prefix}."
|
11
|
+
@tag_proc =
|
12
|
+
if @tag_prefix
|
13
|
+
Proc.new {|tag| "#{@prefix}#{tag}"}
|
14
|
+
else
|
15
|
+
Proc.new {|tag| tag}
|
16
|
+
end
|
17
|
+
@to_s =
|
18
|
+
Proc.new {|record| record.to_s}
|
19
|
+
end
|
20
|
+
|
21
|
+
def emit(tag, es, chain)
|
22
|
+
emit_tag = @tag_proc.call(tag)
|
23
|
+
|
24
|
+
es.each do |time, record|
|
25
|
+
record[@field_name] = record.to_s
|
26
|
+
Fluent::Engine.emit(emit_tag, time, record)
|
27
|
+
end
|
28
|
+
|
29
|
+
chain.next
|
30
|
+
end
|
31
|
+
end
|
data/test/helper.rb
ADDED
@@ -0,0 +1,28 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'bundler'
|
3
|
+
begin
|
4
|
+
Bundler.setup(:default, :development)
|
5
|
+
rescue Bundler::BundlerError => e
|
6
|
+
$stderr.puts e.message
|
7
|
+
$stderr.puts "Run `bundle install` to install missing gems"
|
8
|
+
exit e.status_code
|
9
|
+
end
|
10
|
+
require 'test/unit'
|
11
|
+
|
12
|
+
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
|
13
|
+
$LOAD_PATH.unshift(File.dirname(__FILE__))
|
14
|
+
require 'fluent/test'
|
15
|
+
unless ENV.has_key?('VERBOSE')
|
16
|
+
nulllogger = Object.new
|
17
|
+
nulllogger.instance_eval {|obj|
|
18
|
+
def method_missing(method, *args)
|
19
|
+
# pass
|
20
|
+
end
|
21
|
+
}
|
22
|
+
$log = nulllogger
|
23
|
+
end
|
24
|
+
|
25
|
+
require 'fluent/plugin/out_to_s'
|
26
|
+
|
27
|
+
class Test::Unit::TestCase
|
28
|
+
end
|
@@ -0,0 +1,37 @@
|
|
1
|
+
require 'helper'
|
2
|
+
|
3
|
+
class ToSOutputTest < Test::Unit::TestCase
|
4
|
+
def setup
|
5
|
+
Fluent::Test.setup
|
6
|
+
end
|
7
|
+
|
8
|
+
CONFIG = %[
|
9
|
+
tag_prefix pre_hoge
|
10
|
+
field_name fname_fuga
|
11
|
+
]
|
12
|
+
|
13
|
+
def create_driver(conf = CONFIG, tag='test')
|
14
|
+
Fluent::Test::OutputTestDriver.new(Fluent::ToSOutput, tag).configure(conf)
|
15
|
+
end
|
16
|
+
|
17
|
+
def test_configure
|
18
|
+
d = create_driver
|
19
|
+
assert_equal 'pre_hoge', d.instance.config["tag_prefix"]
|
20
|
+
assert_equal 'fname_fuga', d.instance.config["field_name"]
|
21
|
+
end
|
22
|
+
|
23
|
+
def test_tos
|
24
|
+
d = create_driver
|
25
|
+
time = Time.parse("2011-01-02 13:14:15 UTC").to_i
|
26
|
+
|
27
|
+
d.run do
|
28
|
+
d.emit({"a" => 1})
|
29
|
+
end
|
30
|
+
|
31
|
+
assert_equal [
|
32
|
+
{"a" => 1, d.instance.config["field_name"] => {"a" => 1}.to_s}
|
33
|
+
], d.records
|
34
|
+
|
35
|
+
d.run
|
36
|
+
end
|
37
|
+
end
|
metadata
ADDED
@@ -0,0 +1,97 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: fluent-plugin-to_s
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- airtoxin
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2015-03-30 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ~>
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.3'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ~>
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.3'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - '>='
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - '>='
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: fluentd
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - '>='
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :runtime
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - '>='
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
description: Plugin that adds whole record to to_s field
|
56
|
+
email:
|
57
|
+
- airtoxin@icloud.com
|
58
|
+
executables: []
|
59
|
+
extensions: []
|
60
|
+
extra_rdoc_files: []
|
61
|
+
files:
|
62
|
+
- .gitignore
|
63
|
+
- Gemfile
|
64
|
+
- LICENSE
|
65
|
+
- README.md
|
66
|
+
- Rakefile
|
67
|
+
- fluent-plugin-to_s.gemspec
|
68
|
+
- lib/fluent/plugin/out_to_s.rb
|
69
|
+
- test/helper.rb
|
70
|
+
- test/plugin/test_out_to_s.rb
|
71
|
+
homepage: https://github.com/airtoxin/fluent-plugin-to_s
|
72
|
+
licenses:
|
73
|
+
- MIT
|
74
|
+
metadata: {}
|
75
|
+
post_install_message:
|
76
|
+
rdoc_options: []
|
77
|
+
require_paths:
|
78
|
+
- lib
|
79
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
80
|
+
requirements:
|
81
|
+
- - '>='
|
82
|
+
- !ruby/object:Gem::Version
|
83
|
+
version: '0'
|
84
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
85
|
+
requirements:
|
86
|
+
- - '>='
|
87
|
+
- !ruby/object:Gem::Version
|
88
|
+
version: '0'
|
89
|
+
requirements: []
|
90
|
+
rubyforge_project:
|
91
|
+
rubygems_version: 2.0.14
|
92
|
+
signing_key:
|
93
|
+
specification_version: 4
|
94
|
+
summary: Plugin that adds whole record to to_s field
|
95
|
+
test_files:
|
96
|
+
- test/helper.rb
|
97
|
+
- test/plugin/test_out_to_s.rb
|