act-fluent-logger-rails 0.1.5 → 0.1.6
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 +6 -1
- data/lib/act-fluent-logger-rails/version.rb +1 -1
- data/spec/logger_spec.rb +45 -25
- 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: 029ec3e511f6dbc1e9ca367c6535723d09a3e5e7
|
4
|
+
data.tar.gz: f78130706c3241d68cab6508acd477bbaa350dda
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f8c7eb2eed9222e561c47234520d2158b21aa552f80c3b30dc0486a98ea1d07fc5e2655bbe76bc6368f2ced4bc07b0d10f408ec9d2346c504945c34e03215f6c
|
7
|
+
data.tar.gz: 38df687787843ffe946761d3990d631d486d9e9f648162fe0576cacd37cea8af211ee61d78fa52e6585a4d130d916cb9243212f05796ecf058d071710689315b
|
data/CHANGELOG.md
CHANGED
@@ -74,7 +74,12 @@ module ActFluentLoggerRails
|
|
74
74
|
|
75
75
|
def add_message(severity, message)
|
76
76
|
@severity = severity if @severity < severity
|
77
|
-
|
77
|
+
|
78
|
+
if message.encoding == Encoding::UTF_8
|
79
|
+
@messages << message
|
80
|
+
else
|
81
|
+
@messages << message.dup.force_encoding(Encoding::UTF_8)
|
82
|
+
end
|
78
83
|
end
|
79
84
|
|
80
85
|
def [](key)
|
data/spec/logger_spec.rb
CHANGED
@@ -4,12 +4,10 @@ require 'tempfile'
|
|
4
4
|
|
5
5
|
describe ActFluentLoggerRails::Logger do
|
6
6
|
before do
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
Rails.stub_chain(:application, :config, :log_tags=)
|
12
|
-
end
|
7
|
+
Rails = double("Rails") unless self.class.const_defined?(:Rails)
|
8
|
+
Rails.stub(env: "test")
|
9
|
+
Rails.stub_chain(:application, :config, :log_level).and_return(:debug)
|
10
|
+
Rails.stub_chain(:application, :config, :log_tags=)
|
13
11
|
|
14
12
|
class MyLogger
|
15
13
|
attr_accessor :log
|
@@ -46,25 +44,47 @@ EOF
|
|
46
44
|
})
|
47
45
|
}
|
48
46
|
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
47
|
+
let(:request) {
|
48
|
+
double('request', uuid: 'uuid_value', foo: 'foo_value')
|
49
|
+
}
|
50
|
+
|
51
|
+
describe 'logging' do
|
52
|
+
|
53
|
+
describe 'basic' do
|
54
|
+
it 'info' do
|
55
|
+
logger[:abc] = 'xyz'
|
56
|
+
logger.tagged([request]) { logger.info('hello') }
|
57
|
+
expect(@my_logger.log).to eq([['foo', {
|
58
|
+
abc: 'xyz',
|
59
|
+
messages: ['hello'],
|
60
|
+
level: 'INFO',
|
61
|
+
uuid: 'uuid_value',
|
62
|
+
foo: 'foo_value'
|
63
|
+
} ]])
|
64
|
+
@my_logger.clear
|
65
|
+
logger.tagged([request]) { logger.info('world'); logger.info('bye') }
|
66
|
+
expect(@my_logger.log).to eq([['foo', {
|
67
|
+
messages: ['world', 'bye'],
|
68
|
+
level: 'INFO',
|
69
|
+
uuid: 'uuid_value',
|
70
|
+
foo: 'foo_value'
|
71
|
+
} ]])
|
72
|
+
end
|
73
|
+
end
|
74
|
+
|
75
|
+
describe 'frozen ascii-8bit string' do
|
76
|
+
it 'join messages' do
|
77
|
+
logger.instance_variable_set(:@messages_type, :string)
|
78
|
+
ascii = "\xe8\x8a\xb1".force_encoding('ascii-8bit').freeze
|
79
|
+
logger.tagged([request]) {
|
80
|
+
logger.info(ascii)
|
81
|
+
logger.info('咲く')
|
82
|
+
}
|
83
|
+
expect(@my_logger.log[0][1][:messages]).to eq("花\n咲く")
|
84
|
+
expect(ascii.encoding).to eq(Encoding::ASCII_8BIT)
|
85
|
+
end
|
86
|
+
end
|
87
|
+
|
68
88
|
end
|
69
89
|
|
70
90
|
describe "use ENV['FLUENTD_URL']" do
|
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.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- TAHARA Yoshinori
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2015-03-19 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rspec
|