ougai 1.6.5 → 1.6.6
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 +5 -5
- data/Gemfile.lock +1 -1
- data/lib/ougai.rb +1 -0
- data/lib/ougai/formatters/for_json.rb +2 -6
- data/lib/ougai/serializer.rb +13 -0
- data/lib/ougai/serializers/json_jr_jackson.rb +9 -0
- data/lib/ougai/serializers/json_oj.rb +12 -0
- data/lib/ougai/version.rb +1 -1
- data/spec/logger_spec.rb +1 -1
- metadata +6 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 9f157af11b2825f79fbf60a4db4cbb10b07609d0d640533574904d31fa1a8ed1
|
4
|
+
data.tar.gz: 7b117078406bef661d44c87c3409af0c8e5b8021486bf79ddd25ec157e945abf
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 864a2b7aa5d44ffe192dda4c32970bf53e8d278aeaabcba3073c0c15362fa5edd3594a710dda41cc79dbad7fa8341e6577098c63599b44dadcf49f647afc3a82
|
7
|
+
data.tar.gz: a611c0ae6e1c7b19d0b0952f4438ed0128f65d9f61cd5978cfd38079d117ffc4adaaf84cb3d6e73358ee010d67af4738906981ff4a79568a2e7eefaeec9ff949
|
data/Gemfile.lock
CHANGED
data/lib/ougai.rb
CHANGED
@@ -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 =
|
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,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
|
data/lib/ougai/version.rb
CHANGED
data/spec/logger_spec.rb
CHANGED
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.
|
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-
|
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.
|
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
|