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 +4 -4
- data/CHANGELOG.md +4 -0
- data/lib/act-fluent-logger-rails/logger.rb +10 -1
- data/lib/act-fluent-logger-rails/version.rb +1 -1
- data/spec/logger_spec.rb +20 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 49c7cad6095052ab6f4dca79bb16c7972f934f9c
|
4
|
+
data.tar.gz: c8d2acb86f0ba9f2382a65c1764d8682d962e68c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 248af5b9deb0e572dbf81af0137490bc619104ffe9a58173f6631b50c5e368463fbcdf7da151e977e03ac4f267de00504692e975e07d46e650e6cdd002d2d65c
|
7
|
+
data.tar.gz: c021a43337ae59b7db1d5b7cb677eb8da8b3e278ef77e713a62d8c93dbf676050bc4b3883c90728dd53deedd0fa7ea66febdd7c661460dd019490befac03d2ae
|
data/CHANGELOG.md
CHANGED
@@ -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"),
|
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)
|
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.
|
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-
|
11
|
+
date: 2015-12-23 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rspec
|