ougai 1.4.2 → 1.4.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: fd24ccdad4b3e8fa0a273e6bc4d4a7633b8a2099
4
- data.tar.gz: b4ac8f5e868affc6c44e5592651f68ca634ae3ba
3
+ metadata.gz: 056bac74cd408498f0fb9a5db5f8741094a201ac
4
+ data.tar.gz: 7aec3907ebf359aa409a528a028605c8d4538281
5
5
  SHA512:
6
- metadata.gz: bf27f89b20a9bd241fd329b756be6d1d5cd163bae87dd0c7f51dc8e3b95f6c58dc857fb6e4765c16a1162279465fe2d21378af45323f56acf1e8d02f01028799
7
- data.tar.gz: def31d8b2f563ab7e12e9fea200796177f417b9e3523ee9890c5edb60a647826e477e9c2db412a06b285921e457ddc81cedf516fe86ea500758e53900411a357
6
+ metadata.gz: d1fa397a69c767a637919f3891fba6c5e4a3edadb150483ffce4df6f5870c6f95bc28d33592438c1eabc71c4a2c7f23739e3ce2be8236ed733c65633561b2264
7
+ data.tar.gz: d8a3ff21840a2d0fb328d12d2fd4f643b2512d3e2f55691d4fd0fcab7943b4f22c6e6248dd42aa603e5ff2abf7b0990c068d94a12ff9e7b1d8ccda1ce27f5a8c
data/README.md CHANGED
@@ -369,6 +369,7 @@ logger outputs
369
369
 
370
370
  - [Use as Rails logger](https://github.com/tilfin/ougai/wiki/Use-as-Rails-logger)
371
371
  - [Customize Sidekiq logger](https://github.com/tilfin/ougai/wiki/Customize-Sidekiq-logger)
372
+ - [Forward logs to Fluentd](https://github.com/tilfin/ougai/wiki/Forward-logs-to-Fluentd)
372
373
 
373
374
  ## License
374
375
 
@@ -4,11 +4,12 @@ require 'json'
4
4
  module Ougai
5
5
  module Formatters
6
6
  class Bunyan < Base
7
- attr_accessor :jsonize
7
+ attr_accessor :jsonize, :with_newline
8
8
 
9
9
  def initialize
10
10
  super
11
11
  @jsonize = true
12
+ @with_newline = true
12
13
  end
13
14
 
14
15
  def call(severity, time, progname, data)
@@ -44,7 +45,9 @@ module Ougai
44
45
  def dump(data)
45
46
  return data unless @jsonize
46
47
  data[:time] = data[:time].iso8601(3)
47
- JSON.generate(data) + "\n"
48
+ str = JSON.generate(data)
49
+ str << "\n" if @with_newline
50
+ str
48
51
  end
49
52
  end
50
53
  end
data/lib/ougai/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Ougai
2
- VERSION = "1.4.2"
2
+ VERSION = "1.4.3"
3
3
  end
@@ -20,16 +20,18 @@ describe Ougai::Formatters::Bunyan do
20
20
 
21
21
  let(:formatter) { described_class.new }
22
22
 
23
- context 'when severity is DEBUG' do
24
- subject { JSON.parse(formatter.call('DEBUG', Time.now, nil, data).chomp, symbolize_names: true) }
23
+ context 'jsonize is true and with_newline is true' do
24
+ subject { formatter.call('DEBUG', Time.now, nil, data) }
25
25
 
26
26
  it 'includes valid strings' do
27
- expect(subject).to include(data.merge(level: 20))
28
- expect(subject[:time]).to match(/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}/)
27
+ expect(subject).to end_with("\n")
28
+ result = JSON.parse(subject.chomp, symbolize_names: true)
29
+ expect(result).to include(data.merge(level: 20))
30
+ expect(result[:time]).to match(/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}/)
29
31
  end
30
32
  end
31
33
 
32
- context 'jsonize is falsey' do
34
+ context 'jsonize is false' do
33
35
  before do
34
36
  formatter.jsonize = false
35
37
  end
@@ -79,4 +81,20 @@ describe Ougai::Formatters::Bunyan do
79
81
  end
80
82
  end
81
83
  end
84
+
85
+ context 'with_newline is false' do
86
+ before do
87
+ formatter.with_newline = false
88
+ end
89
+
90
+ subject { formatter.call('INFO', Time.now, nil, data) }
91
+
92
+ it 'includes valid strings' do
93
+ expect(subject).not_to end_with("\n")
94
+ result = JSON.parse(subject, symbolize_names: true)
95
+ expect(result).to include(data.merge(level: 30))
96
+ expect(result[:time]).to match(/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}/)
97
+ end
98
+ end
99
+
82
100
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ougai
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.4.2
4
+ version: 1.4.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Toshimitsu Takahashi
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-08-17 00:00:00.000000000 Z
11
+ date: 2017-08-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler