fluent-plugin-samefile 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 ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 221bc247c772583ac8c3b0766fd24212f750fb5f
4
+ data.tar.gz: cb8bcf286e3019cfbb699194cda488373007c58c
5
+ SHA512:
6
+ metadata.gz: 7e2ae57c08c2b494211446440e380cb2fdb619ab06f7f851d00fecd946f6325c67aa66e27b868fa2d467667591734088279097af29f0e5ddfd691968b5d9ed22
7
+ data.tar.gz: c23a23286a404a91a38c94d9fd2dcdfb37aeaecdedea05ff7b7a2579edd413fe9bb9fb1c163dc575b551d0fb9103e9e16b96785a9691d66b1500d01bb129f4ec
data/.gitignore ADDED
@@ -0,0 +1,22 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
18
+ *.bundle
19
+ *.so
20
+ *.o
21
+ *.a
22
+ mkmf.log
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in fluent-plugin-samefile.gemspec
4
+ gemspec
data/LICENSE ADDED
@@ -0,0 +1,13 @@
1
+ Copyright 2015 Yuri UMEZAKI
2
+
3
+ Licensed under the Apache License, Version 2.0 (the "License");
4
+ you may not use this file except in compliance with the License.
5
+ You may obtain a copy of the License at
6
+
7
+ http://www.apache.org/licenses/LICENSE-2.0
8
+
9
+ Unless required by applicable law or agreed to in writing, software
10
+ distributed under the License is distributed on an "AS IS" BASIS,
11
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ See the License for the specific language governing permissions and
13
+ limitations under the License.
data/README.md ADDED
@@ -0,0 +1,48 @@
1
+ # Fluent-plugin-samefile
2
+
3
+ [Fluentd](http://fluentd.org) filter plugin to output same file.
4
+
5
+
6
+ ## Installation
7
+
8
+ ```bash
9
+ # for fluentd
10
+ $ gem install fluent-plugin-samefile
11
+
12
+ # for td-agent2
13
+ $ sudo td-agent-gem install fluent-plugin-samefile
14
+ ```
15
+
16
+
17
+ ## Usage
18
+
19
+ ```xml
20
+ <match pattern>
21
+ type samefile
22
+ path /var/log/fluent/myapp.log
23
+ </match>
24
+ ```
25
+
26
+
27
+ ## TODO
28
+
29
+ * patches welcome!
30
+
31
+
32
+ ## Contributing
33
+
34
+ 1. Fork it ( https://github.com/bungoume/fluent-plugin-samefile/fork )
35
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
36
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
37
+ 4. Push to the branch (`git push origin my-new-feature`)
38
+ 5. Create a new Pull Request
39
+
40
+
41
+ ## Copyright
42
+
43
+ Copyright (c) 2015 Yuri Umezaki
44
+
45
+
46
+ ## License
47
+
48
+ Apache License, Version 2.0
data/Rakefile ADDED
@@ -0,0 +1,2 @@
1
+ require "bundler/gem_tasks"
2
+
@@ -0,0 +1,22 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+
5
+ Gem::Specification.new do |spec|
6
+ spec.name = "fluent-plugin-samefile"
7
+ spec.version = "0.0.1"
8
+ spec.authors = ["Yuri Umezaki"]
9
+ spec.email = ["bungoume@gmail.com"]
10
+ spec.homepage = "https://github.com/bungoume/fluent-plugin-samefile"
11
+ spec.summary = "Fluentd filter plugin to output same file"
12
+ spec.description = spec.summary
13
+ spec.license = "APLv2"
14
+
15
+ spec.files = `git ls-files -z`.split("\x0")
16
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
17
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
18
+ spec.require_paths = ["lib"]
19
+
20
+ spec.add_runtime_dependency "fluentd"
21
+ spec.add_development_dependency "rake"
22
+ end
@@ -0,0 +1,54 @@
1
+ require "fluent/plugin/samefile/version"
2
+
3
+ module Fluent
4
+ class SameFileOutput < Output
5
+ Plugin.register_output('samefile', self)
6
+
7
+ config_param :path, :string
8
+ config_param :format, :string, :default => 'out_file'
9
+
10
+ def initialize
11
+ super
12
+ end
13
+
14
+ def configure(conf)
15
+ if path = conf['path']
16
+ @path = path
17
+ end
18
+ unless @path
19
+ raise ConfigError, "'path' parameter is required on file output"
20
+ end
21
+
22
+ super
23
+
24
+ FileUtils.mkdir_p File.dirname(@path)
25
+
26
+ conf['format'] = @format
27
+ @formatter = TextFormatter.create(conf)
28
+ end
29
+
30
+ def format(tag, time, record)
31
+ @formatter.format(tag, time, record)
32
+ end
33
+
34
+ def write(data)
35
+ File.open(@path, "a", DEFAULT_FILE_PERMISSION) do |f|
36
+ f.write(data)
37
+ end
38
+ end
39
+
40
+ def emit(tag, es, chain, key="")
41
+ data = format_stream(tag, es)
42
+ write(data)
43
+ end
44
+
45
+ def format_stream(tag, es)
46
+ out = ''
47
+ es.each {|time,record|
48
+ out << format(tag, time, record)
49
+ }
50
+ out
51
+ end
52
+
53
+ end
54
+ end
metadata ADDED
@@ -0,0 +1,79 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: fluent-plugin-samefile
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Yuri Umezaki
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2015-07-12 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: fluentd
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
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
+ description: Fluentd filter plugin to output same file
42
+ email:
43
+ - bungoume@gmail.com
44
+ executables: []
45
+ extensions: []
46
+ extra_rdoc_files: []
47
+ files:
48
+ - ".gitignore"
49
+ - Gemfile
50
+ - LICENSE
51
+ - README.md
52
+ - Rakefile
53
+ - fluent-plugin-samefile.gemspec
54
+ - lib/fluent/plugin/out_samefile.rb
55
+ homepage: https://github.com/bungoume/fluent-plugin-samefile
56
+ licenses:
57
+ - APLv2
58
+ metadata: {}
59
+ post_install_message:
60
+ rdoc_options: []
61
+ require_paths:
62
+ - lib
63
+ required_ruby_version: !ruby/object:Gem::Requirement
64
+ requirements:
65
+ - - ">="
66
+ - !ruby/object:Gem::Version
67
+ version: '0'
68
+ required_rubygems_version: !ruby/object:Gem::Requirement
69
+ requirements:
70
+ - - ">="
71
+ - !ruby/object:Gem::Version
72
+ version: '0'
73
+ requirements: []
74
+ rubyforge_project:
75
+ rubygems_version: 2.4.8
76
+ signing_key:
77
+ specification_version: 4
78
+ summary: Fluentd filter plugin to output same file
79
+ test_files: []