act-fluent-logger-rails 0.1.9 → 0.1.10

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: 550119ac05199783efccabc275c43ce73de465b3
4
- data.tar.gz: 67e8d75dda8d2d08a5fd42f725e0c6a09bc34f6e
3
+ metadata.gz: 49c7cad6095052ab6f4dca79bb16c7972f934f9c
4
+ data.tar.gz: c8d2acb86f0ba9f2382a65c1764d8682d962e68c
5
5
  SHA512:
6
- metadata.gz: 3a24306a282669279ce745f47c717e81e05011caa2ff0285eb62d92e8a23fd48fcddd9829a49b4dd19e96a4f0bc969fd655b524161f89aa4f7da392c692cb2d3
7
- data.tar.gz: 699d6cf7a3974d26a3c492a5885049bd322bb7c4e07f25839aa81a3434c16a907d9767e5eba9215a5d3d524e7c4d3d4f015834c8574bb728e8f98271adca0c6e
6
+ metadata.gz: 248af5b9deb0e572dbf81af0137490bc619104ffe9a58173f6631b50c5e368463fbcdf7da151e977e03ac4f267de00504692e975e07d46e650e6cdd002d2d65c
7
+ data.tar.gz: c021a43337ae59b7db1d5b7cb677eb8da8b3e278ef77e713a62d8c93dbf676050bc4b3883c90728dd53deedd0fa7ea66febdd7c661460dd019490befac03d2ae
data/CHANGELOG.md CHANGED
@@ -1,3 +1,7 @@
1
+ ## 0.1.10 / Dec 23 2015
2
+
3
+ * flush immediately.
4
+
1
5
  ## 0.1.9 / Dec 16 2015
2
6
 
3
7
  * Added settings: parameter to ActFluentLoggerRails::Logger.new.
@@ -11,7 +11,10 @@ module ActFluentLoggerRails
11
11
  # Severity label for logging. (max 5 char)
12
12
  SEV_LABEL = %w(DEBUG INFO WARN ERROR FATAL ANY)
13
13
 
14
- def self.new(config_file: Rails.root.join("config", "fluent-logger.yml"), log_tags: {}, settings: {})
14
+ def self.new(config_file: Rails.root.join("config", "fluent-logger.yml"),
15
+ log_tags: {},
16
+ settings: {},
17
+ flush_immediately: false)
15
18
  Rails.application.config.log_tags = [ ->(request) { request } ] unless log_tags.empty?
16
19
  if (0 == settings.length)
17
20
  fluent_config = if ENV["FLUENTD_URL"]
@@ -26,6 +29,9 @@ module ActFluentLoggerRails
26
29
  messages_type: fluent_config['messages_type'],
27
30
  }
28
31
  end
32
+
33
+ settings[:flush_immediately] ||= flush_immediately
34
+
29
35
  level = SEV_LABEL.index(Rails.application.config.log_level.to_s.upcase)
30
36
  logger = ActFluentLoggerRails::FluentLogger.new(settings, level, log_tags)
31
37
  logger = ActiveSupport::TaggedLogging.new(logger)
@@ -59,6 +65,7 @@ module ActFluentLoggerRails
59
65
  host = options[:host]
60
66
  @messages_type = (options[:messages_type] || :array).to_sym
61
67
  @tag = options[:tag]
68
+ @flush_immediately = options[:flush_immediately]
62
69
  @fluent_logger = ::Fluent::Logger::FluentLogger.new(nil, host: host, port: port)
63
70
  @severity = 0
64
71
  @messages = []
@@ -93,6 +100,8 @@ module ActFluentLoggerRails
93
100
  else
94
101
  @messages << message.dup.force_encoding(Encoding::UTF_8)
95
102
  end
103
+
104
+ flush if @flush_immediately
96
105
  end
97
106
 
98
107
  def [](key)
@@ -1,3 +1,3 @@
1
1
  module ActFluentLoggerRails
2
- VERSION = "0.1.9"
2
+ VERSION = "0.1.10"
3
3
  end
data/spec/logger_spec.rb CHANGED
@@ -128,4 +128,24 @@ EOF
128
128
  it { expect(subject['messages_type']).to eq 'string' }
129
129
  end
130
130
  end
131
+
132
+ describe 'flush_immediately' do
133
+ describe 'flush_immediately: true' do
134
+ it 'flushed' do
135
+ logger = ActFluentLoggerRails::Logger.new(config_file: File.new(@config_file.path),
136
+ flush_immediately: true)
137
+ logger.info('Immediately!')
138
+ expect(@my_logger.log[0][1][:messages][0]).to eq('Immediately!')
139
+ end
140
+ end
141
+
142
+ describe 'flush_immediately: false' do
143
+ it 'flushed' do
144
+ logger = ActFluentLoggerRails::Logger.new(config_file: File.new(@config_file.path),
145
+ flush_immediately: false)
146
+ logger.info('Immediately!')
147
+ expect(@my_logger.log).to eq(nil)
148
+ end
149
+ end
150
+ end
131
151
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: act-fluent-logger-rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.9
4
+ version: 0.1.10
5
5
  platform: ruby
6
6
  authors:
7
7
  - TAHARA Yoshinori
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-12-16 00:00:00.000000000 Z
11
+ date: 2015-12-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rspec