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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: b8948529fa64435096f9be2f85e103b34268652a
4
- data.tar.gz: 588ce44194197d65ca7528941e931107296bd255
3
+ metadata.gz: 029ec3e511f6dbc1e9ca367c6535723d09a3e5e7
4
+ data.tar.gz: f78130706c3241d68cab6508acd477bbaa350dda
5
5
  SHA512:
6
- metadata.gz: 207a1c5007dca5360349c02224f70a95398fa9fa17a9d702cb94a2708a2e005cde466011f5df88de16df6a3bc7c995d068268b0f8527b3b589fd39396aa6e994
7
- data.tar.gz: 9249a4c66f68484277066328e07e5a457f4a28e411497400cb170a798f8a0bc12992e03859c99e0d9efe96d06736e60352bbe390a6dcfda844fa8576ca6c8e87
6
+ metadata.gz: f8c7eb2eed9222e561c47234520d2158b21aa552f80c3b30dc0486a98ea1d07fc5e2655bbe76bc6368f2ced4bc07b0d10f408ec9d2346c504945c34e03215f6c
7
+ data.tar.gz: 38df687787843ffe946761d3990d631d486d9e9f648162fe0576cacd37cea8af211ee61d78fa52e6585a4d130d916cb9243212f05796ecf058d071710689315b
data/CHANGELOG.md CHANGED
@@ -1,3 +1,7 @@
1
+ ## 0.1.6 / March 20 2015
2
+
3
+ * Fix incompatible character encodings #13.
4
+
1
5
  ## 0.1.5 / July 19 2014
2
6
 
3
7
  * Fix keynames of EVN['FLUENTD_URL']
@@ -74,7 +74,12 @@ module ActFluentLoggerRails
74
74
 
75
75
  def add_message(severity, message)
76
76
  @severity = severity if @severity < severity
77
- @messages << message
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)
@@ -1,3 +1,3 @@
1
1
  module ActFluentLoggerRails
2
- VERSION = "0.1.5"
2
+ VERSION = "0.1.6"
3
3
  end
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
- unless self.class.const_defined?(:Rails)
9
- Rails = double("Rails", env: "test")
10
- Rails.stub_chain(:application, :config, :log_level).and_return(:debug)
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
- it 'info' do
50
- request = double('request', uuid: 'uuid_value', foo: 'foo_value')
51
- logger[:abc] = 'xyz'
52
- logger.tagged([request]) { logger.info('hello') }
53
- expect(@my_logger.log).to eq([['foo', {
54
- abc: 'xyz',
55
- messages: ['hello'],
56
- level: 'INFO',
57
- uuid: 'uuid_value',
58
- foo: 'foo_value'
59
- } ]])
60
- @my_logger.clear
61
- logger.tagged([request]) { logger.info('world'); logger.info('bye') }
62
- expect(@my_logger.log).to eq([['foo', {
63
- messages: ['world', 'bye'],
64
- level: 'INFO',
65
- uuid: 'uuid_value',
66
- foo: 'foo_value'
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.5
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: 2014-07-19 00:00:00.000000000 Z
11
+ date: 2015-03-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rspec