ougai 1.6.5 → 1.6.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
- SHA1:
3
- metadata.gz: 19e44070a0143cd04e7b874389e53a46032065cb
4
- data.tar.gz: 18dc7eb966f376c057a75a4e9fc3d243eff2d853
2
+ SHA256:
3
+ metadata.gz: 9f157af11b2825f79fbf60a4db4cbb10b07609d0d640533574904d31fa1a8ed1
4
+ data.tar.gz: 7b117078406bef661d44c87c3409af0c8e5b8021486bf79ddd25ec157e945abf
5
5
  SHA512:
6
- metadata.gz: 631e1f0dea4f969cedef17930a09754ed3b3f00dbdeb306b38e572beffb82198c6d8aeb1d9eb81244221579094238c392d9feb46a1e465524a4b96ab6863e370
7
- data.tar.gz: 51573402bd3bd1dc8e2f00d5d2d1d76dafc841bade69c2079425f8f03b9a380ee102af93cd0b45100977cf3edf0a2529713523d713933b2fbcd7889a9d25fa13
6
+ metadata.gz: 864a2b7aa5d44ffe192dda4c32970bf53e8d278aeaabcba3073c0c15362fa5edd3594a710dda41cc79dbad7fa8341e6577098c63599b44dadcf49f647afc3a82
7
+ data.tar.gz: a611c0ae6e1c7b19d0b0952f4438ed0128f65d9f61cd5978cfd38079d117ffc4adaaf84cb3d6e73358ee010d67af4738906981ff4a79568a2e7eefaeec9ff949
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- ougai (1.6.5)
4
+ ougai (1.6.6)
5
5
  oj (~> 3.4)
6
6
 
7
7
  GEM
@@ -6,5 +6,6 @@ require 'ougai/formatters/for_json'
6
6
  require 'ougai/formatters/bunyan'
7
7
  require 'ougai/formatters/readable'
8
8
  require 'ougai/formatters/pino'
9
+ require 'ougai/serializer'
9
10
  require 'ougai/child_logger'
10
11
  require 'ougai/logger'
@@ -1,5 +1,3 @@
1
- require 'oj'
2
-
3
1
  module Ougai
4
2
  # The features for JSON formatter
5
3
  # @attr [Boolean] jsonize Whether log should converts JSON
@@ -12,6 +10,7 @@ module Ougai
12
10
  def init_opts_for_json(opts)
13
11
  @jsonize = opts.fetch(:jsonize, true)
14
12
  @with_newline = opts.fetch(:with_newline, true)
13
+ @serializer = Ougai::Serializer.for_json
15
14
  end
16
15
 
17
16
  def to_level(severity)
@@ -33,14 +32,11 @@ module Ougai
33
32
  end
34
33
  end
35
34
 
36
- OJ_OPTIONS = { mode: :custom, time_format: :xmlschema,
37
- use_as_json: true, use_to_hash: true, use_to_json: true }
38
-
39
35
  # requires convert_time(data) method
40
36
  def dump(data)
41
37
  return data unless @jsonize
42
38
  convert_time(data)
43
- str = Oj.dump(data, OJ_OPTIONS)
39
+ str = @serializer.serialize(data)
44
40
  str << "\n" if @with_newline
45
41
  str
46
42
  end
@@ -0,0 +1,13 @@
1
+ module Ougai
2
+ class Serializer
3
+ def self.for_json
4
+ if RUBY_PLATFORM =~ /java/
5
+ require 'ougai/serializers/json_jr_jackson'
6
+ Serializers::JsonJrJackson.new
7
+ else
8
+ require 'ougai/serializers/json_oj'
9
+ Serializers::JsonOj.new
10
+ end
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,9 @@
1
+ require 'jrjackson'
2
+
3
+ module Ougai::Serializers
4
+ class JsonJrJackson < Ougai::Serializer
5
+ def serialize(data)
6
+ JrJackson::Json.dump(data)
7
+ end
8
+ end
9
+ end
@@ -0,0 +1,12 @@
1
+ require 'oj'
2
+
3
+ module Ougai::Serializers
4
+ class JsonOj < Ougai::Serializer
5
+ OJ_OPTIONS = { mode: :custom, time_format: :xmlschema,
6
+ use_as_json: true, use_to_hash: true, use_to_json: true }
7
+
8
+ def serialize(data)
9
+ Oj.dump(data, OJ_OPTIONS)
10
+ end
11
+ end
12
+ end
@@ -1,3 +1,3 @@
1
1
  module Ougai
2
- VERSION = '1.6.5'
2
+ VERSION = '1.6.6'
3
3
  end
@@ -29,7 +29,7 @@ describe Ougai::Logger do
29
29
  err = actual[:err]
30
30
  err[:message] == expected \
31
31
  && err[:name] = 'StandardError' \
32
- && err[:stack].include?('ougai/spec')
32
+ && err[:stack].include?('<main>')
33
33
  end
34
34
  end
35
35
 
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.6.5
4
+ version: 1.6.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: 2018-03-08 00:00:00.000000000 Z
11
+ date: 2018-05-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: oj
@@ -89,6 +89,9 @@ files:
89
89
  - lib/ougai/formatters/readable.rb
90
90
  - lib/ougai/logger.rb
91
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
92
95
  - lib/ougai/version.rb
93
96
  - spec/child_logger_spec.rb
94
97
  - spec/formatters/base_spec.rb
@@ -119,7 +122,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
119
122
  version: '0'
120
123
  requirements: []
121
124
  rubyforge_project:
122
- rubygems_version: 2.6.13
125
+ rubygems_version: 2.7.3
123
126
  signing_key:
124
127
  specification_version: 4
125
128
  summary: JSON logger compatible with node-bunyan or pino is capable of handling structured