ougai 1.7.1-java

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,54 @@
1
+ require 'spec_helper'
2
+
3
+ describe Ougai::Logging do
4
+ subject do
5
+ m = described_class
6
+ Class.new { include m }.new
7
+ end
8
+
9
+ describe '#weak_merge!' do
10
+ it 'merges with unique elements in array' do
11
+ result = nil
12
+ subject.instance_eval do
13
+ result = weak_merge!({ foo: [1, 2], bar: 'base', baz: ['A'] },
14
+ { foo: [2, 3], bar: 'inferior', baz: ['B'] })
15
+ end
16
+ expect(result[:foo]).to eq([2, 3, 1])
17
+ expect(result[:bar]).to eq('base')
18
+ expect(result[:baz]).to eq(['B', 'A'])
19
+ end
20
+ end
21
+
22
+ describe '#child' do
23
+ let!(:fields) { double('fields') }
24
+ let!(:child_logger) { double('child logger') }
25
+
26
+ context 'block is not given' do
27
+ it 'returns child logger' do
28
+ expect(Ougai::ChildLogger).to receive(:new).with(subject, fields).and_return(child_logger)
29
+ expect(subject.child(fields)).to eq(child_logger)
30
+ end
31
+ end
32
+
33
+ context 'block is given' do
34
+ it 'passes child logger' do
35
+ expect(Ougai::ChildLogger).to receive(:new).with(subject, fields).and_return(child_logger)
36
+ subject.child(fields) do |cl|
37
+ expect(cl).to eq(child_logger)
38
+ end
39
+ end
40
+ end
41
+ end
42
+
43
+ describe '#chain' do
44
+ it 'is not implemented' do
45
+ expect{ subject.chain(:arg1, :arg2, :arg3, :arg4) }.to raise_error(NotImplementedError)
46
+ end
47
+ end
48
+
49
+ describe '#append' do
50
+ it 'is not implemented' do
51
+ expect{ subject.send(:append, :arg1, :arg2) }.to raise_error(NotImplementedError)
52
+ end
53
+ end
54
+ end
@@ -0,0 +1,7 @@
1
+ require 'spec_helper'
2
+
3
+ describe Ougai do
4
+ it 'has a version number' do
5
+ expect(Ougai::VERSION).not_to be nil
6
+ end
7
+ end
@@ -0,0 +1,78 @@
1
+ require 'timecop'
2
+ require 'simplecov'
3
+ SimpleCov.start do
4
+ add_filter "/spec/"
5
+ end
6
+
7
+ $LOAD_PATH.unshift File.expand_path('../../lib', __FILE__)
8
+ require 'ougai'
9
+
10
+ RSpec.shared_examples 'formatter#initialize' do |params|
11
+ describe '#initialize' do
12
+ let(:app_name) { 'dummy app name' }
13
+ let(:hostname) { 'dummyhost' }
14
+ let(:options) { params[:options] }
15
+
16
+ subject { described_class.new(*arguments) }
17
+
18
+ context 'with app_name' do
19
+ let!(:arguments) { [app_name] }
20
+
21
+ it 'creates an instance with valid app_name and hostname' do
22
+ expect(subject.app_name).to eq(app_name)
23
+ expect(subject.hostname).to eq(Socket.gethostname.force_encoding('UTF-8'))
24
+ params[:default_opts].each do |key, val|
25
+ expect(subject.send(key)).to eq(val)
26
+ end
27
+ end
28
+ end
29
+
30
+ context 'with options' do
31
+ let!(:arguments) { [options] }
32
+
33
+ it 'creates an instance with valid values for attributes' do
34
+ expect(subject.app_name).to eq('rspec')
35
+ expect(subject.hostname).to eq(Socket.gethostname.force_encoding('UTF-8'))
36
+ options.each do |key, val|
37
+ expect(subject.send(key)).to eq(val)
38
+ end
39
+ end
40
+ end
41
+
42
+ context 'with app_name and hostname' do
43
+ let!(:arguments) { [app_name, hostname] }
44
+
45
+ it 'creates an instance with valid app_name and hostname' do
46
+ expect(subject.app_name).to eq(app_name)
47
+ expect(subject.hostname).to eq(hostname)
48
+ params[:default_opts].each do |key, val|
49
+ expect(subject.send(key)).to eq(val)
50
+ end
51
+ end
52
+ end
53
+
54
+ context 'with app_name and options' do
55
+ let!(:arguments) { [app_name, options] }
56
+
57
+ it 'creates an instance with valid values for attributes' do
58
+ expect(subject.app_name).to eq(app_name)
59
+ expect(subject.hostname).to eq(Socket.gethostname.force_encoding('UTF-8'))
60
+ options.each do |key, val|
61
+ expect(subject.send(key)).to eq(val)
62
+ end
63
+ end
64
+ end
65
+
66
+ context 'with app_name, hostname and options' do
67
+ let!(:arguments) { [app_name, hostname, options] }
68
+
69
+ it 'creates an instance with valid values for attributes' do
70
+ expect(subject.app_name).to eq(app_name)
71
+ expect(subject.hostname).to eq(hostname)
72
+ options.each do |key, val|
73
+ expect(subject.send(key)).to eq(val)
74
+ end
75
+ end
76
+ end
77
+ end
78
+ end
metadata ADDED
@@ -0,0 +1,139 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: ougai
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.7.1
5
+ platform: java
6
+ authors:
7
+ - Toshimitsu Takahashi
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2018-11-30 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ requirement: !ruby/object:Gem::Requirement
15
+ requirements:
16
+ - - "~>"
17
+ - !ruby/object:Gem::Version
18
+ version: '0.4'
19
+ name: jrjackson
20
+ prerelease: false
21
+ type: :runtime
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '0.4'
27
+ - !ruby/object:Gem::Dependency
28
+ requirement: !ruby/object:Gem::Requirement
29
+ requirements:
30
+ - - "~>"
31
+ - !ruby/object:Gem::Version
32
+ version: '1.11'
33
+ name: bundler
34
+ prerelease: false
35
+ type: :development
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '1.11'
41
+ - !ruby/object:Gem::Dependency
42
+ requirement: !ruby/object:Gem::Requirement
43
+ requirements:
44
+ - - "~>"
45
+ - !ruby/object:Gem::Version
46
+ version: '10.0'
47
+ name: rake
48
+ prerelease: false
49
+ type: :development
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '10.0'
55
+ - !ruby/object:Gem::Dependency
56
+ requirement: !ruby/object:Gem::Requirement
57
+ requirements:
58
+ - - "~>"
59
+ - !ruby/object:Gem::Version
60
+ version: '3.0'
61
+ name: rspec
62
+ prerelease: false
63
+ type: :development
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '3.0'
69
+ description: |2
70
+ A structured logging system is capable of handling a message, custom data or an exception easily.
71
+ It has JSON formatters compatible with Bunyan or pino for Node.js and human readable formatter with Awesome Print for console.
72
+ email:
73
+ - toshi@tilfin.com
74
+ executables: []
75
+ extensions: []
76
+ extra_rdoc_files: []
77
+ files:
78
+ - Gemfile
79
+ - Gemfile.lock
80
+ - LICENSE.txt
81
+ - README.md
82
+ - Rakefile
83
+ - lib/ougai.rb
84
+ - lib/ougai/child_logger.rb
85
+ - lib/ougai/formatters/base.rb
86
+ - lib/ougai/formatters/bunyan.rb
87
+ - lib/ougai/formatters/for_json.rb
88
+ - lib/ougai/formatters/pino.rb
89
+ - lib/ougai/formatters/readable.rb
90
+ - lib/ougai/logger.rb
91
+ - lib/ougai/logging.rb
92
+ - lib/ougai/serializer.rb
93
+ - lib/ougai/serializers/json_jr_jackson.rb
94
+ - lib/ougai/serializers/json_oj.rb
95
+ - lib/ougai/version.rb
96
+ - spec/child_logger_spec.rb
97
+ - spec/formatters/base_spec.rb
98
+ - spec/formatters/bunyan_spec.rb
99
+ - spec/formatters/pino_spec.rb
100
+ - spec/formatters/readable_spec.rb
101
+ - spec/logger_spec.rb
102
+ - spec/logging_spec.rb
103
+ - spec/ougai_spec.rb
104
+ - spec/spec_helper.rb
105
+ homepage: https://github.com/tilfin/ougai
106
+ licenses:
107
+ - MIT
108
+ metadata: {}
109
+ post_install_message:
110
+ rdoc_options: []
111
+ require_paths:
112
+ - lib
113
+ required_ruby_version: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - ">="
116
+ - !ruby/object:Gem::Version
117
+ version: 2.3.0
118
+ required_rubygems_version: !ruby/object:Gem::Requirement
119
+ requirements:
120
+ - - ">="
121
+ - !ruby/object:Gem::Version
122
+ version: '0'
123
+ requirements: []
124
+ rubyforge_project:
125
+ rubygems_version: 2.6.14.1
126
+ signing_key:
127
+ specification_version: 4
128
+ summary: JSON logger compatible with node-bunyan or pino is capable of handling structured
129
+ data easily.
130
+ test_files:
131
+ - spec/child_logger_spec.rb
132
+ - spec/logging_spec.rb
133
+ - spec/logger_spec.rb
134
+ - spec/ougai_spec.rb
135
+ - spec/spec_helper.rb
136
+ - spec/formatters/pino_spec.rb
137
+ - spec/formatters/base_spec.rb
138
+ - spec/formatters/bunyan_spec.rb
139
+ - spec/formatters/readable_spec.rb