chihiro 0.3.11 → 0.3.12

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
  SHA256:
3
- metadata.gz: a0fb1bc70beea448e8ace7b5c7a44029e41b142421154fcb030f3436d365749e
4
- data.tar.gz: efba1554b0d4cfb4283903f0e4711e54854f4d3723aeaaea622b5240e3efbe04
3
+ metadata.gz: 7f3a7f945a807a2a39be4e4949d76fbdc50c81022ce8996b7e43fe39e2791086
4
+ data.tar.gz: 7f1de9e938be11ffa65fab760e3910b2a703cac2745f8b4852a929a863d9a4f8
5
5
  SHA512:
6
- metadata.gz: c40b93ae14703871809a43b63236d9867afc830123373d3cb76e6b0b25c7c88962745a4811772e416f4fc79a84ca4d2a8613075b2da307f0fbb54d47d08b49ae
7
- data.tar.gz: 9c18132dc713a361960408e3341d972fd79259bb11616bcfbc4b3c7a40f425307cc3d714f1130f43df3adec2895d5f573b8440bd5463dfbf5e8ca17cf57b1305
6
+ metadata.gz: 96e2a771ad80db10e22aa5a1f975617871d495fa5263e1701c1ff2b361ee2dd0ac00d036ca1ca8e4694cfc978746914ea3113858d08dd66c626e63e387a26834
7
+ data.tar.gz: 3958e0bb63195360f668f298e1151151c6d9a1e18576adbe4c8b3130d40255c9835d9a8de1310df6e0019e8400adba3635953bfc0262cbec1fa50cc81860d6f9
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- chihiro (0.3.0)
4
+ chihiro (0.3.12)
5
5
  lograge (~> 0.10)
6
6
 
7
7
  GEM
@@ -0,0 +1,12 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Chihiro
4
+ class FlattenUtil
5
+ class << self
6
+ def flat(hash)
7
+ return hash unless hash.is_a? Hash
8
+ hash.map { |k, v| [k, v.to_s] }.to_h
9
+ end
10
+ end
11
+ end
12
+ end
@@ -1,5 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require 'logger'
4
+
3
5
  module Chihiro
4
6
  class JsonLogFormatter < ::Logger::Formatter
5
7
  def call(severity, _time, _progname, msg)
@@ -19,7 +21,7 @@ module Chihiro
19
21
 
20
22
  def extra_log_data(msg)
21
23
  if msg.is_a? Hash
22
- MaskUtil.mask(msg)
24
+ FlattenUtil.flat(MaskUtil.mask(msg))
23
25
  elsif msg.is_a? Exception
24
26
  { message: msg.message, backtrace: msg.backtrace }
25
27
  else
@@ -1,3 +1,5 @@
1
+ require 'active_support'
2
+
1
3
  module Chihiro
2
4
  module Loggable
3
5
  extend ActiveSupport::Concern
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Chihiro
4
- VERSION = '0.3.11'
4
+ VERSION = '0.3.12'
5
5
  end
data/lib/chihiro.rb CHANGED
@@ -3,6 +3,7 @@
3
3
  require 'chihiro/version'
4
4
  require 'chihiro/initializer'
5
5
  require 'chihiro/mask_util'
6
+ require 'chihiro/flatten_util'
6
7
  require 'chihiro/json_log_formatter'
7
8
  require 'chihiro/loggable'
8
9
 
Binary file
@@ -0,0 +1,22 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'spec_helper'
4
+
5
+ RSpec.describe Chihiro::FlattenUtil do
6
+ it 'should flat a nested hash' do
7
+ msg = {
8
+ password: '***',
9
+ message: 'abc',
10
+ aaa: {
11
+ password: '***',
12
+ other: 'otherMsg'
13
+ }
14
+ }
15
+
16
+ result = Chihiro::FlattenUtil.flat(msg)
17
+
18
+ expect(result).to eq({ password: '***',
19
+ message: 'abc',
20
+ aaa: "{:password=>\"***\", :other=>\"otherMsg\"}" })
21
+ end
22
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: chihiro
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.11
4
+ version: 0.3.12
5
5
  platform: ruby
6
6
  authors:
7
7
  - Shu Hui
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-03-07 00:00:00.000000000 Z
11
+ date: 2019-03-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: lograge
@@ -97,6 +97,7 @@ files:
97
97
  - bin/setup
98
98
  - chihiro.gemspec
99
99
  - lib/chihiro.rb
100
+ - lib/chihiro/flatten_util.rb
100
101
  - lib/chihiro/initializer.rb
101
102
  - lib/chihiro/json_log_formatter.rb
102
103
  - lib/chihiro/loggable.rb
@@ -106,6 +107,7 @@ files:
106
107
  - lib/generators/chihiro/templates/initializer.rb
107
108
  - pkg/chihiro-0.3.11.gem
108
109
  - spec/chihiro_spec.rb
110
+ - spec/flatten_util_spec.rb
109
111
  - spec/mask_util_spec.rb
110
112
  - spec/spec_helper.rb
111
113
  homepage: https://github.com/blockchaintech-au/chihiro