ougai 1.5.5 → 1.5.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: da3e50121cd1ca747fdf84a266ab60d0fe8d71eb
4
- data.tar.gz: 3c93d87d0c32eb0e6a30c0ab0577b537476b3de8
3
+ metadata.gz: b0be28a9823a80734981fe6333f87b5369e61094
4
+ data.tar.gz: 4fee2e596d358d32409c86e46235539bfc796dee
5
5
  SHA512:
6
- metadata.gz: 3c7eed367fc984d280ac8f4cfb802c1836ec2918b57dc1c233ab4084585ef115e12d451cafd7c10d0014be7d2d31ea92c877bef8b4e1a2ab02a8947c0b180e42
7
- data.tar.gz: 875f603ca33e5349c2edc0a2cec508b39afb4fab9db4545fec82369c1c7a8e383abcd2afb48da8ce597e669eaca357f686a7cc9e633920ac3a5a1d24ae097f10
6
+ metadata.gz: 1845cb73f37a0a48406f66d24dc68dcc2f6d6f4a161feaae880ab20557baf7bac77d1032fcfe131e028cd9e6c866f52949e3bf2e74dfdea0e728799912b5d2ea
7
+ data.tar.gz: ea9ac008a278ae1e879c5fdaf7080c9e2e0dbca1f781f4deade03c794eba36dd894d0bab6568c7a2d88681737a163cfa95b9801db7b5dbd566891071c8dbb170
data/README.md CHANGED
@@ -350,6 +350,7 @@ logger.formatter = Ougai::Formatters::Readable.new
350
350
  - [Forward logs to Fluentd](https://github.com/tilfin/ougai/wiki/Forward-logs-to-Fluentd)
351
351
  - [Forward logs to Logentries](https://github.com/tilfin/ougai/wiki/Forward-logs-to-Logentries)
352
352
  - [Use as ServerEngine logger](https://github.com/tilfin/ougai/wiki/Use-as-ServerEngine-logger)
353
+ - [Forward logs to Loggly](https://github.com/tilfin/ougai/wiki/Forward-logs-to-Loggly)
353
354
 
354
355
  ## License
355
356
 
@@ -46,14 +46,14 @@ module Ougai
46
46
  # @private
47
47
  def chain(severity, args, fields, hooks)
48
48
  hooks.push(@before_log) if @before_log
49
- @parent.chain(severity, args, merge_fields(@with_fields, fields), hooks)
49
+ @parent.chain(severity, args, weak_merge!(fields, @with_fields), hooks)
50
50
  end
51
51
 
52
52
  protected
53
53
 
54
54
  def append(severity, args)
55
55
  hooks = @before_log ? [@before_log] : []
56
- @parent.chain(severity, args, @with_fields, hooks)
56
+ @parent.chain(severity, args, @with_fields.dup, hooks)
57
57
  end
58
58
  end
59
59
  end
@@ -9,8 +9,8 @@ module Ougai
9
9
  class Bunyan < Base
10
10
  attr_accessor :jsonize, :with_newline
11
11
 
12
- def initialize
13
- super
12
+ def initialize(*args)
13
+ super(*args)
14
14
  @jsonize = true
15
15
  @with_newline = true
16
16
  end
@@ -59,7 +59,7 @@ module Ougai
59
59
  # @private
60
60
  def chain(severity, args, fields, hooks)
61
61
  hooks.push(@before_log) if @before_log
62
- write(severity, args, merge_fields(@with_fields, fields), hooks)
62
+ write(severity, args, weak_merge!(fields, @with_fields), hooks)
63
63
  end
64
64
 
65
65
  protected
@@ -81,7 +81,7 @@ module Ougai
81
81
  end
82
82
 
83
83
  def write(severity, args, fields, hooks)
84
- data = merge_fields(fields, to_item(args))
84
+ data = weak_merge!(to_item(args), fields)
85
85
  hooks.each do |hook|
86
86
  return false if hook.call(data) == false
87
87
  end
@@ -102,12 +102,12 @@ module Ougai
102
102
  end
103
103
 
104
104
  # @private
105
- def merge_fields(base_data, new_data)
106
- base_data.merge(new_data) do |_, base_val, new_val|
107
- if base_val.is_a?(Array) and new_val.is_a?(Array)
108
- (base_val + new_val).uniq
105
+ def weak_merge!(base_data, inferior_data)
106
+ base_data.merge!(inferior_data) do |_, base_v, inferior_v|
107
+ if base_v.is_a?(Array) and inferior_v.is_a?(Array)
108
+ (inferior_v + base_v).uniq
109
109
  else
110
- new_val
110
+ base_v
111
111
  end
112
112
  end
113
113
  end
@@ -1,3 +1,3 @@
1
1
  module Ougai
2
- VERSION = "1.5.5"
2
+ VERSION = "1.5.6"
3
3
  end
@@ -20,6 +20,15 @@ describe Ougai::Formatters::Bunyan do
20
20
 
21
21
  let(:formatter) { described_class.new }
22
22
 
23
+ context '#initialize' do
24
+ let(:appname) { 'dummy app name' }
25
+
26
+ it 'suceeds with arguments' do
27
+ fmt = described_class.new(appname)
28
+ expect(fmt.app_name).to eq(appname)
29
+ end
30
+ end
31
+
23
32
  context 'jsonize is true and with_newline is true' do
24
33
  subject { formatter.call('DEBUG', Time.now, nil, data) }
25
34
 
@@ -1,18 +1,18 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  describe Ougai::Logging do
4
- describe '#merge_fields' do
4
+ describe '#weak_merge!' do
5
5
  let(:target) { m = described_class; Class.new{ include m }.new }
6
6
 
7
7
  it 'merges with unique elements in array' do
8
8
  result = nil
9
9
  target.instance_eval do
10
- result = merge_fields({ foo: [1, 2], bar: 'base', baz: ['A'] },
11
- { foo: [2, 3], bar: 'over', baz: ['B'] })
10
+ result = weak_merge!({ foo: [1, 2], bar: 'base', baz: ['A'] },
11
+ { foo: [2, 3], bar: 'inferior', baz: ['B'] })
12
12
  end
13
- expect(result[:foo]).to eq([1, 2, 3])
14
- expect(result[:bar]).to eq('over')
15
- expect(result[:baz]).to eq(['A', 'B'])
13
+ expect(result[:foo]).to eq([2, 3, 1])
14
+ expect(result[:bar]).to eq('base')
15
+ expect(result[:baz]).to eq(['B', 'A'])
16
16
  end
17
17
  end
18
18
  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.5.5
4
+ version: 1.5.6
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-09-21 00:00:00.000000000 Z
11
+ date: 2017-11-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -103,17 +103,17 @@ required_rubygems_version: !ruby/object:Gem::Requirement
103
103
  version: '0'
104
104
  requirements: []
105
105
  rubyforge_project:
106
- rubygems_version: 2.6.13
106
+ rubygems_version: 2.6.11
107
107
  signing_key:
108
108
  specification_version: 4
109
109
  summary: JSON logger compatible with node-bunyan is capable of handling structured
110
110
  data easily.
111
111
  test_files:
112
+ - spec/child_logger_spec.rb
112
113
  - spec/formatters/base_spec.rb
113
114
  - spec/formatters/bunyan_spec.rb
114
115
  - spec/formatters/readable_spec.rb
115
- - spec/child_logger_spec.rb
116
- - spec/logging_spec.rb
117
116
  - spec/logger_spec.rb
117
+ - spec/logging_spec.rb
118
118
  - spec/ougai_spec.rb
119
119
  - spec/spec_helper.rb