fluent-plugin-file-alternative 0.1.4 → 0.1.5

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 717fa824f86b1d9e7efd9a2c72bc90745886bd85
4
+ data.tar.gz: 53299516fbc595bc4083fa1859f76764759ab003
5
+ SHA512:
6
+ metadata.gz: 5bb40a237167cb760d77ef7c9d50b8ee390f12a541d633f79d656e7c64efb88ec4f12e1ef3d5513dcf32fc0b62a45fd69d1642e8e178cb61eb35812351050295
7
+ data.tar.gz: fd7c06f49331ce0b890bc2e38a2b6db7ad387cc2ce7bfe3746f39b82c78526277938a02259384b6eb77bf4dc04520567b316bb032640ff2cabf95b5c677eec2f
@@ -0,0 +1,4 @@
1
+ language: ruby
2
+ rvm:
3
+ - 1.9.3
4
+ - 2.0.0
data/README.md CHANGED
@@ -1,6 +1,7 @@
1
- # fluent-plugin-file-alternative
1
+ # fluent-plugin-file-alternative
2
2
 
3
- File output plugin alternative implementation, **is 100% compatible with fluentd built-in 'out_file'**, and added many options to format output as you want.
3
+ File output plugin alternative implementation, **is 100% compatible with
4
+ [Fluentd](http://fluentd.org) built-in 'out_file'**, and added many options to format output as you want.
4
5
 
5
6
  FileAlternativeOutput slices data by time (for specified units), and store these data as plain text on local file. You can specify to:
6
7
 
@@ -22,6 +23,10 @@ And you can specify output file path as:
22
23
 
23
24
  And, gzip compression is also supported.
24
25
 
26
+ -### Why this is not a patch for out_file?
27
+ -
28
+ -`fluent-plugin-file-alternative` has optimized buffer data structure to make faster to write data on disk. But that buffer structure is not compatible with `out_file`'s one. That's tha reason why this plugin is an another plugin from `out_file`.
29
+
25
30
  ## Configuration
26
31
 
27
32
  ### FileAlternativeOutput
@@ -29,9 +34,9 @@ And, gzip compression is also supported.
29
34
  Standard out_file way (hourly log, compression, time-tag-json):
30
35
 
31
36
  <match out.**>
32
- type file\_alternative
37
+ type file_alternative
33
38
  path /var/log/service/access.*.log
34
- time\_slice\_output %Y%m%d_%H
39
+ time_slice_output %Y%m%d_%H
35
40
  compress gzip
36
41
  </match>
37
42
 
@@ -45,7 +50,7 @@ By this configuration, in gzip compressed file '/var/log/service/access.20120316
45
50
  If you don't want fluentd-time and tag in written file, and messages with single attribute (as raw full apache log with newline):
46
51
 
47
52
  <match out.**>
48
- type file\_alternative
53
+ type file_alternative
49
54
  path /var/log/service/access.%Y%m%d_%H.log
50
55
  compress gzip
51
56
  output_include_time false
@@ -2,19 +2,21 @@
2
2
 
3
3
  Gem::Specification.new do |gem|
4
4
  gem.name = "fluent-plugin-file-alternative"
5
- gem.version = "0.1.4"
5
+ gem.version = "0.1.5"
6
6
 
7
7
  gem.authors = ["TAGOMORI Satoshi"]
8
8
  gem.email = ["tagomoris@gmail.com"]
9
9
  gem.description = %q{alternative implementation of out_file, with various configurations}
10
10
  gem.summary = %q{alternative implementation of out_file}
11
11
  gem.homepage = "https://github.com/tagomoris/fluent-plugin-file-alternative"
12
+ gem.license = "APLv2"
12
13
 
13
14
  gem.files = `git ls-files`.split($\)
14
15
  gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
15
16
  gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
16
17
  gem.require_paths = ["lib"]
17
18
 
18
- gem.add_runtime_dependency "fluentd"
19
+ gem.add_runtime_dependency "fluentd", ">= 0.10.39" # This version for @buffer.symlink_path
19
20
  gem.add_runtime_dependency "fluent-mixin-plaintextformatter"
21
+ gem.add_development_dependency "rake"
20
22
  end
@@ -3,6 +3,11 @@ require 'fluent/mixin/plaintextformatter'
3
3
  class Fluent::FileAlternativeOutput < Fluent::TimeSlicedOutput
4
4
  Fluent::Plugin.register_output('file_alternative', self)
5
5
 
6
+ # Define `log` method for v0.10.42 or earlier
7
+ unless method_defined?(:log)
8
+ define_method("log") { $log }
9
+ end
10
+
6
11
  SUPPORTED_COMPRESS = {
7
12
  :gz => :gz,
8
13
  :gzip => :gz,
@@ -20,6 +25,8 @@ class Fluent::FileAlternativeOutput < Fluent::TimeSlicedOutput
20
25
  c
21
26
  end
22
27
 
28
+ config_param :symlink_path, :string, :default => nil
29
+
23
30
  include Fluent::Mixin::PlainTextFormatter
24
31
 
25
32
  def initialize
@@ -60,6 +67,13 @@ class Fluent::FileAlternativeOutput < Fluent::TimeSlicedOutput
60
67
  unless @path.index('/') == 0
61
68
  raise Fluent::ConfigError, "Path on filesystem MUST starts with '/', but '#{@path}'"
62
69
  end
70
+
71
+ if @symlink_path
72
+ unless @symlink_path.index('/') == 0
73
+ raise Fluent::ConfigError, "Symlink path on filesystem MUST starts with '/', but '#{@symlink_path}'"
74
+ end
75
+ @buffer.symlink_path = @symlink_path
76
+ end
63
77
  end
64
78
 
65
79
  def start
@@ -132,7 +146,7 @@ class Fluent::FileAlternativeOutput < Fluent::TimeSlicedOutput
132
146
  }
133
147
  end
134
148
  rescue
135
- $log.error "failed to write data: path #{path}"
149
+ log.error "failed to write data: path #{path}"
136
150
  raise
137
151
  end
138
152
  path
@@ -8,6 +8,8 @@ class FileAlternativeOutputTest < Test::Unit::TestCase
8
8
  compress gz
9
9
  ]
10
10
 
11
+ SYMLINK_PATH = File.expand_path("#{TMP_DIR}/current")
12
+
11
13
  def setup
12
14
  Fluent::Test.setup
13
15
  FileUtils.rm_rf(TMP_DIR)
@@ -128,4 +130,29 @@ class FileAlternativeOutputTest < Test::Unit::TestCase
128
130
  path = d3.run
129
131
  assert_equal "#{TMP_DIR}/accesslog.2011-01-02-13-14-15.gz", path[0]
130
132
  end
133
+
134
+ def test_write_with_symlink
135
+ conf = CONFIG + %[
136
+ symlink_path #{SYMLINK_PATH}
137
+ ]
138
+ symlink_path = "#{SYMLINK_PATH}"
139
+
140
+ d = create_driver(conf)
141
+ time = Time.parse("2011-01-02 13:14:15 UTC").to_i
142
+ d.emit({"a"=>1}, time)
143
+ d.run
144
+ assert File.exists?(symlink_path)
145
+ assert File.symlink?(symlink_path)
146
+
147
+ d.instance.start
148
+ begin
149
+ 10.times { sleep 0.05 }
150
+ d.instance.enqueue_buffer
151
+
152
+ assert !File.exists?(symlink_path)
153
+ assert File.symlink?(symlink_path)
154
+ ensure
155
+ d.instance.shutdown
156
+ end
157
+ end
131
158
  end
metadata CHANGED
@@ -1,46 +1,55 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fluent-plugin-file-alternative
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.4
5
- prerelease:
4
+ version: 0.1.5
6
5
  platform: ruby
7
6
  authors:
8
7
  - TAGOMORI Satoshi
9
8
  autorequire:
10
9
  bindir: bin
11
10
  cert_chain: []
12
- date: 2013-04-08 00:00:00.000000000 Z
11
+ date: 2014-03-07 00:00:00.000000000 Z
13
12
  dependencies:
14
13
  - !ruby/object:Gem::Dependency
15
14
  name: fluentd
16
15
  requirement: !ruby/object:Gem::Requirement
17
- none: false
18
16
  requirements:
19
- - - ! '>='
17
+ - - ">="
20
18
  - !ruby/object:Gem::Version
21
- version: '0'
19
+ version: 0.10.39
22
20
  type: :runtime
23
21
  prerelease: false
24
22
  version_requirements: !ruby/object:Gem::Requirement
25
- none: false
26
23
  requirements:
27
- - - ! '>='
24
+ - - ">="
28
25
  - !ruby/object:Gem::Version
29
- version: '0'
26
+ version: 0.10.39
30
27
  - !ruby/object:Gem::Dependency
31
28
  name: fluent-mixin-plaintextformatter
32
29
  requirement: !ruby/object:Gem::Requirement
33
- none: false
34
30
  requirements:
35
- - - ! '>='
31
+ - - ">="
36
32
  - !ruby/object:Gem::Version
37
33
  version: '0'
38
34
  type: :runtime
39
35
  prerelease: false
40
36
  version_requirements: !ruby/object:Gem::Requirement
41
- none: false
42
37
  requirements:
43
- - - ! '>='
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rake
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
44
53
  - !ruby/object:Gem::Version
45
54
  version: '0'
46
55
  description: alternative implementation of out_file, with various configurations
@@ -50,7 +59,8 @@ executables: []
50
59
  extensions: []
51
60
  extra_rdoc_files: []
52
61
  files:
53
- - .gitignore
62
+ - ".gitignore"
63
+ - ".travis.yml"
54
64
  - Gemfile
55
65
  - LICENSE.txt
56
66
  - README.md
@@ -61,28 +71,28 @@ files:
61
71
  - test/plugin/test_out_file_alternative.rb
62
72
  - test/plugin/test_out_file_original.rb
63
73
  homepage: https://github.com/tagomoris/fluent-plugin-file-alternative
64
- licenses: []
74
+ licenses:
75
+ - APLv2
76
+ metadata: {}
65
77
  post_install_message:
66
78
  rdoc_options: []
67
79
  require_paths:
68
80
  - lib
69
81
  required_ruby_version: !ruby/object:Gem::Requirement
70
- none: false
71
82
  requirements:
72
- - - ! '>='
83
+ - - ">="
73
84
  - !ruby/object:Gem::Version
74
85
  version: '0'
75
86
  required_rubygems_version: !ruby/object:Gem::Requirement
76
- none: false
77
87
  requirements:
78
- - - ! '>='
88
+ - - ">="
79
89
  - !ruby/object:Gem::Version
80
90
  version: '0'
81
91
  requirements: []
82
92
  rubyforge_project:
83
- rubygems_version: 1.8.23
93
+ rubygems_version: 2.2.2
84
94
  signing_key:
85
- specification_version: 3
95
+ specification_version: 4
86
96
  summary: alternative implementation of out_file
87
97
  test_files:
88
98
  - test/helper.rb