fluent-logger 0.7.2 → 0.8.0

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: 534a2ccb4ce18b0c8082c309d464d6291ede39f5
4
- data.tar.gz: d57458f299eccdff242de08e5d6ea03d2cee4ed3
3
+ metadata.gz: eb07188f881f645087ed46e08dcb033abd3e78f3
4
+ data.tar.gz: c5e7715e87ebf4bb7ca5f5a0afb6297d4772011b
5
5
  SHA512:
6
- metadata.gz: e5f6dc505d218591c81b5945f894aef62551610a404f8ce6e68b88f5bed88165b9a931a22cd99e3f02180575b0d6d367d617dcd287d544914eecbcf03b349b3f
7
- data.tar.gz: 3e4f91caab8f1d472709611867dbe6e3ade664d0fe954123f08e193a18922e359bb7ca3665f04d552ba7432db2802dd1dd322d7cfcc3bcbda49c83724d19109a
6
+ metadata.gz: 44b031f5063e83cac44e704f8a3fe95d1fa8bdf732f68dad096bd6da73b41c31c480412c00c1fe006f9b2bd6285e626f6ab6bc3096115ac559c3961ffd3c9a59
7
+ data.tar.gz: d3929bbf74cc3e77fc76149f98a0cd001f34213a715c807290cdc7bdc88df35d4d11d07d963a6a765ad144552ee99fb8cb191d7dce8f28e91e4e4c5c053ef37c
@@ -1,10 +1,10 @@
1
1
  rvm:
2
- - 1.9.3
3
- - 2.0.0
4
2
  - 2.1
5
3
  - 2.2
6
- - 2.3.1
7
- - 2.4.0
4
+ - 2.3.7
5
+ - 2.4.5
6
+ - 2.5.3
7
+ - 2.6.0
8
8
  - ruby-head
9
9
 
10
10
  gemfile:
@@ -20,15 +20,15 @@ matrix:
20
20
  allow_failures:
21
21
  - rvm: ruby-head
22
22
  exclude:
23
- - rvm: 1.9.3
24
- gemfile: Gemfile
25
- - rvm: 2.0.0
26
- gemfile: Gemfile
27
23
  - rvm: 2.2
28
24
  gemfile: Gemfile.v0.12
29
- - rvm: 2.3.1
25
+ - rvm: 2.3.7
30
26
  gemfile: Gemfile.v0.12
31
- - rvm: 2.4.0
27
+ - rvm: 2.4.5
28
+ gemfile: Gemfile.v0.12
29
+ - rvm: 2.5.3
30
+ gemfile: Gemfile.v0.12
31
+ - rvm: 2.6.0
32
32
  gemfile: Gemfile.v0.12
33
33
  - rvm: ruby-head
34
34
  gemfile: Gemfile.v0.12
data/ChangeLog CHANGED
@@ -1,3 +1,7 @@
1
+ Release 0.8.0 - 2019/01/25
2
+
3
+ * Add use_nonblock and wait_writeable parameters
4
+
1
5
  Release 0.7.2 - 2018/01/04
2
6
 
3
7
  * Fix EventTime for nanosecond_precision
data/README.md CHANGED
@@ -11,6 +11,7 @@ A structured event logger
11
11
  ```ruby
12
12
  require 'fluent-logger'
13
13
 
14
+ # API: FluentLogger.new(tag_prefix, options)
14
15
  log = Fluent::Logger::FluentLogger.new(nil, :host => 'localhost', :port => 24224)
15
16
  unless log.post("myapp.access", {"agent" => "foo"})
16
17
  p log.last_error # You can get last error object via last_error method
@@ -32,26 +33,71 @@ end
32
33
  # output: myapp.access {"agent":"foo"}
33
34
  ```
34
35
 
35
- ### Singleton
36
+ ### Tag prefix
36
37
  ```ruby
37
38
  require 'fluent-logger'
38
39
 
39
- Fluent::Logger::FluentLogger.open(nil, :host => 'localhost', :port => 24224)
40
- Fluent::Logger.post("myapp.access", {"agent" => "foo"})
40
+ log = Fluent::Logger::FluentLogger.new('myapp', :host => 'localhost', :port => 24224)
41
+ log.post("access", {"agent" => "foo"})
41
42
 
42
43
  # output: myapp.access {"agent":"foo"}
43
44
  ```
44
45
 
45
- ### Tag prefix
46
+ ### Nonblocking write
47
+
46
48
  ```ruby
47
49
  require 'fluent-logger'
48
50
 
49
- log = Fluent::Logger::FluentLogger.new('myapp', :host => 'localhost', :port => 24224)
50
- log.post("access", {"agent" => "foo"})
51
+ log = Fluent::Logger::FluentLogger.new(nil, :host => 'localhost', :port => 24224, :use_nonblock => true, :wait_writeable => false)
52
+ begin
53
+ log.post("myapp.access", {"agent" => "foo"})
54
+ rescue IO::EAGAINWaitWritable => e
55
+ # wait code for avoding "Resource temporarily unavailable"
56
+ end
57
+
58
+ # output: myapp.access {"agent":"foo"}
59
+ ```
60
+
61
+ ### Singleton
62
+ ```ruby
63
+ require 'fluent-logger'
64
+
65
+ Fluent::Logger::FluentLogger.open(nil, :host => 'localhost', :port => 24224)
66
+ Fluent::Logger.post("myapp.access", {"agent" => "foo"})
51
67
 
52
68
  # output: myapp.access {"agent":"foo"}
53
69
  ```
54
70
 
71
+ ### Logger options
72
+
73
+ #### host (String)
74
+
75
+ fluentd instance host
76
+
77
+ #### port (Integer)
78
+
79
+ fluentd instance port
80
+
81
+ #### socket_path (String)
82
+
83
+ If specified, fluentd uses unix domain socket instead of TCP.
84
+
85
+ #### nanosecond_precision (Bool)
86
+
87
+ Use nano second event time instead of epoch. See also "Tips" section.
88
+
89
+ #### use_nonblock (Bool)
90
+
91
+ Use nonblocking write(`IO#write_nonblock`) instead of normal write(`IO#write`). If `Logger#post` stuck on your environment, specify `true`.
92
+
93
+ #### wait_writeable (Bool)
94
+
95
+ If `true`, `Logger#post` raises an error when nonblocking write gets `EAGAIN`.
96
+
97
+ #### buffer_overflow_handler (Proc)
98
+
99
+ Pass callback for handling buffer overflow with pending data. See "Buffer overflow" section.
100
+
55
101
  ### Standard ::Logger compatible interface
56
102
 
57
103
  #### Example1
@@ -1,18 +1,10 @@
1
1
  # encoding: utf-8
2
2
  $:.push File.expand_path('../lib', __FILE__)
3
+ require 'fluent/logger/version'
3
4
 
4
5
  Gem::Specification.new do |gem|
5
6
  version_file = "lib/fluent/logger/version.rb"
6
- version = File.read("VERSION").strip
7
- File.open(version_file, "w") {|f|
8
- f.write <<EOF
9
- module Fluent
10
- module Logger
11
- VERSION = '#{version}'
12
- end
13
- end
14
- EOF
15
- }
7
+ version = Fluent::Logger::VERSION
16
8
 
17
9
  gem.name = %q{fluent-logger}
18
10
  gem.version = version
@@ -27,6 +19,7 @@ EOF
27
19
  gem.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
28
20
  gem.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
29
21
  gem.require_paths = ['lib']
22
+ gem.license = "Apache-2.0"
30
23
 
31
24
  gem.add_dependency "msgpack", ">= 1.0.0", "< 2"
32
25
  gem.add_development_dependency 'rake', '>= 0.9.2'
@@ -64,7 +64,8 @@ module Fluent
64
64
 
65
65
  options = {
66
66
  :host => 'localhost',
67
- :port => 24224
67
+ :port => 24224,
68
+ :use_nonblock => false
68
69
  }
69
70
 
70
71
  case args.first
@@ -81,6 +82,7 @@ module Fluent
81
82
  @port = options[:port]
82
83
  @socket_path = options[:socket_path]
83
84
  @nanosecond_precision = options[:nanosecond_precision]
85
+ @use_nonblock = options[:use_nonblock]
84
86
 
85
87
  @factory = MessagePack::Factory.new
86
88
  if @nanosecond_precision
@@ -96,8 +98,8 @@ module Fluent
96
98
  @log_reconnect_error_threshold = options[:log_reconnect_error_threshold] || RECONNECT_WAIT_MAX_COUNT
97
99
 
98
100
  @buffer_overflow_handler = options[:buffer_overflow_handler]
99
- if logger = options[:logger]
100
- @logger = logger
101
+ if options[:logger]
102
+ @logger = options[:logger]
101
103
  else
102
104
  @logger = ::Logger.new(STDERR)
103
105
  if options[:debug]
@@ -107,6 +109,9 @@ module Fluent
107
109
  end
108
110
  end
109
111
 
112
+ @wait_writeable = true
113
+ @wait_writeable = options[:wait_writeable] if options.key?(:wait_writeable)
114
+
110
115
  @last_error = {}
111
116
 
112
117
  begin
@@ -229,6 +234,9 @@ module Fluent
229
234
  @pending = nil
230
235
  true
231
236
  rescue => e
237
+ unless wait_writeable?(e)
238
+ raise e
239
+ end
232
240
  set_last_error(e)
233
241
  if pending_bytesize > @limit
234
242
  @logger.error("FluentLogger: Can't send logs to #{connection_string}: #{$!}")
@@ -246,7 +254,11 @@ module Fluent
246
254
  unless connect?
247
255
  connect!
248
256
  end
249
- @con.write data
257
+ if @use_nonblock
258
+ @con.write_nonblock data
259
+ else
260
+ @con.write data
261
+ end
250
262
  #while true
251
263
  # puts "sending #{data.length} bytes"
252
264
  # if data.length > 32*1024
@@ -298,6 +310,14 @@ module Fluent
298
310
  # TODO: Check non GVL env
299
311
  @last_error[Thread.current.object_id] = e
300
312
  end
313
+
314
+ def wait_writeable?(e)
315
+ if e.instance_of?(IO::EAGAINWaitWritable)
316
+ @wait_writeable
317
+ else
318
+ true
319
+ end
320
+ end
301
321
  end
302
322
  end
303
323
  end
@@ -1,5 +1,5 @@
1
1
  module Fluent
2
2
  module Logger
3
- VERSION = '0.7.2'
3
+ VERSION = '0.8.0'
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fluent-logger
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.7.2
4
+ version: 0.8.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sadayuki Furuhashi
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-01-04 00:00:00.000000000 Z
11
+ date: 2019-01-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: msgpack
@@ -117,7 +117,6 @@ files:
117
117
  - Gemfile.v0.12
118
118
  - README.md
119
119
  - Rakefile
120
- - VERSION
121
120
  - bin/fluent-post
122
121
  - fluent-logger.gemspec
123
122
  - lib/fluent-logger.rb
@@ -144,7 +143,8 @@ files:
144
143
  - spec/support/timecop.rb
145
144
  - spec/test_logger_spec.rb
146
145
  homepage: https://github.com/fluent/fluent-logger-ruby
147
- licenses: []
146
+ licenses:
147
+ - Apache-2.0
148
148
  metadata: {}
149
149
  post_install_message:
150
150
  rdoc_options: []
@@ -162,7 +162,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
162
162
  version: '0'
163
163
  requirements: []
164
164
  rubyforge_project:
165
- rubygems_version: 2.6.13
165
+ rubygems_version: 2.6.14.1
166
166
  signing_key:
167
167
  specification_version: 4
168
168
  summary: fluent logger for ruby
data/VERSION DELETED
@@ -1 +0,0 @@
1
- 0.7.2