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 +4 -4
- data/README.md +1 -0
- data/lib/ougai/child_logger.rb +2 -2
- data/lib/ougai/formatters/bunyan.rb +2 -2
- data/lib/ougai/logger.rb +2 -2
- data/lib/ougai/logging.rb +5 -5
- data/lib/ougai/version.rb +1 -1
- data/spec/formatters/bunyan_spec.rb +9 -0
- data/spec/logging_spec.rb +6 -6
- metadata +5 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b0be28a9823a80734981fe6333f87b5369e61094
|
4
|
+
data.tar.gz: 4fee2e596d358d32409c86e46235539bfc796dee
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
|
data/lib/ougai/child_logger.rb
CHANGED
@@ -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,
|
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
|
data/lib/ougai/logger.rb
CHANGED
@@ -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,
|
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 =
|
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
|
data/lib/ougai/logging.rb
CHANGED
@@ -102,12 +102,12 @@ module Ougai
|
|
102
102
|
end
|
103
103
|
|
104
104
|
# @private
|
105
|
-
def
|
106
|
-
base_data.merge(
|
107
|
-
if
|
108
|
-
(
|
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
|
-
|
110
|
+
base_v
|
111
111
|
end
|
112
112
|
end
|
113
113
|
end
|
data/lib/ougai/version.rb
CHANGED
@@ -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
|
|
data/spec/logging_spec.rb
CHANGED
@@ -1,18 +1,18 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
describe Ougai::Logging do
|
4
|
-
describe '#
|
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 =
|
11
|
-
|
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([
|
14
|
-
expect(result[:bar]).to eq('
|
15
|
-
expect(result[:baz]).to eq(['
|
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.
|
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-
|
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.
|
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
|