pier_logging 0.2.2 → 0.3.1

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: 15b02b57cc80e8d5babe64aa73a7b29c2d1fac544acc2c069c7cb0ba4ee985fc
4
- data.tar.gz: 13719e2b027929f1e385928a943a96200db798c008be2a4f7895c075ea34fefe
3
+ metadata.gz: '04659db491f4230e2dcc6bb313fe9f9ca4b9563c0b4b705bc61777112eb52327'
4
+ data.tar.gz: ee82d54e3ff4bc24a2ad78b7d42f78cc3c2fe031a9c93c349981e959eebcc4d0
5
5
  SHA512:
6
- metadata.gz: edcd064cef708218bc0c4fb6e2e2d0ae13737b41a666c14be34129ff5ef008dedf734e33b93fa6e5c82cff95e1ca2bc76f0dcdfc39ed944509dc2742d4c56fb6
7
- data.tar.gz: 170036ef60fecdf8cc77b8aa51f5ac4e40e89f29e90fd8410d9c6a65f98a43ecf4f73f0ab79d8db865cd4a38a6fab5bb4da420f00b8d0129e314943c4f2e31f2
6
+ metadata.gz: 8dd5860cfe2b8ca25b8218a4f934cd828d35c1efbf776ebd40e0e34eaf8e2726b32ebc9da108e278068acf5a1b66831869f6f7342731454ed27ae19f8d06a822
7
+ data.tar.gz: bec737e90c8c6e41cd121409a4a2df80a187ef509a2c7b3bce9580c8e024ff3cff509fc5462892ad487cebf1f3682335072c403fb0516007847272bed3d6767a
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- pier_logging (0.1.7)
4
+ pier_logging (0.3.0)
5
5
  awesome_print
6
6
  facets
7
7
  ougai
@@ -10,73 +10,77 @@ PATH
10
10
  GEM
11
11
  remote: https://rubygems.org/
12
12
  specs:
13
- actioncable (6.0.3.2)
14
- actionpack (= 6.0.3.2)
13
+ actioncable (6.1.1)
14
+ actionpack (= 6.1.1)
15
+ activesupport (= 6.1.1)
15
16
  nio4r (~> 2.0)
16
17
  websocket-driver (>= 0.6.1)
17
- actionmailbox (6.0.3.2)
18
- actionpack (= 6.0.3.2)
19
- activejob (= 6.0.3.2)
20
- activerecord (= 6.0.3.2)
21
- activestorage (= 6.0.3.2)
22
- activesupport (= 6.0.3.2)
18
+ actionmailbox (6.1.1)
19
+ actionpack (= 6.1.1)
20
+ activejob (= 6.1.1)
21
+ activerecord (= 6.1.1)
22
+ activestorage (= 6.1.1)
23
+ activesupport (= 6.1.1)
23
24
  mail (>= 2.7.1)
24
- actionmailer (6.0.3.2)
25
- actionpack (= 6.0.3.2)
26
- actionview (= 6.0.3.2)
27
- activejob (= 6.0.3.2)
25
+ actionmailer (6.1.1)
26
+ actionpack (= 6.1.1)
27
+ actionview (= 6.1.1)
28
+ activejob (= 6.1.1)
29
+ activesupport (= 6.1.1)
28
30
  mail (~> 2.5, >= 2.5.4)
29
31
  rails-dom-testing (~> 2.0)
30
- actionpack (6.0.3.2)
31
- actionview (= 6.0.3.2)
32
- activesupport (= 6.0.3.2)
33
- rack (~> 2.0, >= 2.0.8)
32
+ actionpack (6.1.1)
33
+ actionview (= 6.1.1)
34
+ activesupport (= 6.1.1)
35
+ rack (~> 2.0, >= 2.0.9)
34
36
  rack-test (>= 0.6.3)
35
37
  rails-dom-testing (~> 2.0)
36
38
  rails-html-sanitizer (~> 1.0, >= 1.2.0)
37
- actiontext (6.0.3.2)
38
- actionpack (= 6.0.3.2)
39
- activerecord (= 6.0.3.2)
40
- activestorage (= 6.0.3.2)
41
- activesupport (= 6.0.3.2)
39
+ actiontext (6.1.1)
40
+ actionpack (= 6.1.1)
41
+ activerecord (= 6.1.1)
42
+ activestorage (= 6.1.1)
43
+ activesupport (= 6.1.1)
42
44
  nokogiri (>= 1.8.5)
43
- actionview (6.0.3.2)
44
- activesupport (= 6.0.3.2)
45
+ actionview (6.1.1)
46
+ activesupport (= 6.1.1)
45
47
  builder (~> 3.1)
46
48
  erubi (~> 1.4)
47
49
  rails-dom-testing (~> 2.0)
48
50
  rails-html-sanitizer (~> 1.1, >= 1.2.0)
49
- activejob (6.0.3.2)
50
- activesupport (= 6.0.3.2)
51
+ activejob (6.1.1)
52
+ activesupport (= 6.1.1)
51
53
  globalid (>= 0.3.6)
52
- activemodel (6.0.3.2)
53
- activesupport (= 6.0.3.2)
54
- activerecord (6.0.3.2)
55
- activemodel (= 6.0.3.2)
56
- activesupport (= 6.0.3.2)
57
- activestorage (6.0.3.2)
58
- actionpack (= 6.0.3.2)
59
- activejob (= 6.0.3.2)
60
- activerecord (= 6.0.3.2)
54
+ activemodel (6.1.1)
55
+ activesupport (= 6.1.1)
56
+ activerecord (6.1.1)
57
+ activemodel (= 6.1.1)
58
+ activesupport (= 6.1.1)
59
+ activestorage (6.1.1)
60
+ actionpack (= 6.1.1)
61
+ activejob (= 6.1.1)
62
+ activerecord (= 6.1.1)
63
+ activesupport (= 6.1.1)
61
64
  marcel (~> 0.3.1)
62
- activesupport (6.0.3.2)
65
+ mimemagic (~> 0.3.2)
66
+ activesupport (6.1.1)
63
67
  concurrent-ruby (~> 1.0, >= 1.0.2)
64
- i18n (>= 0.7, < 2)
65
- minitest (~> 5.1)
66
- tzinfo (~> 1.1)
67
- zeitwerk (~> 2.2, >= 2.2.2)
68
+ i18n (>= 1.6, < 2)
69
+ minitest (>= 5.1)
70
+ tzinfo (~> 2.0)
71
+ zeitwerk (~> 2.3)
68
72
  awesome_print (1.8.0)
69
73
  builder (3.2.4)
70
74
  byebug (11.1.3)
71
- concurrent-ruby (1.1.6)
75
+ concurrent-ruby (1.1.7)
72
76
  crass (1.0.6)
73
- erubi (1.9.0)
77
+ erubi (1.10.0)
74
78
  facets (3.1.0)
75
79
  globalid (0.4.2)
76
80
  activesupport (>= 4.2.0)
77
- i18n (1.8.3)
81
+ i18n (1.8.7)
78
82
  concurrent-ruby (~> 1.0)
79
- loofah (2.6.0)
83
+ loofah (2.8.0)
80
84
  crass (~> 1.0.2)
81
85
  nokogiri (>= 1.5.9)
82
86
  mail (2.7.1)
@@ -86,59 +90,60 @@ GEM
86
90
  method_source (1.0.0)
87
91
  mimemagic (0.3.5)
88
92
  mini_mime (1.0.2)
89
- mini_portile2 (2.4.0)
93
+ mini_portile2 (2.5.0)
90
94
  minitest (5.14.1)
91
- nio4r (2.5.2)
92
- nokogiri (1.10.9)
93
- mini_portile2 (~> 2.4.0)
94
- oj (3.10.6)
95
+ nio4r (2.5.4)
96
+ nokogiri (1.11.1)
97
+ mini_portile2 (~> 2.5.0)
98
+ racc (~> 1.4)
99
+ oj (3.10.18)
95
100
  ougai (1.8.5)
96
101
  oj (~> 3.10)
102
+ racc (1.5.2)
97
103
  rack (2.2.3)
98
104
  rack-test (1.1.0)
99
105
  rack (>= 1.0, < 3)
100
- rails (6.0.3.2)
101
- actioncable (= 6.0.3.2)
102
- actionmailbox (= 6.0.3.2)
103
- actionmailer (= 6.0.3.2)
104
- actionpack (= 6.0.3.2)
105
- actiontext (= 6.0.3.2)
106
- actionview (= 6.0.3.2)
107
- activejob (= 6.0.3.2)
108
- activemodel (= 6.0.3.2)
109
- activerecord (= 6.0.3.2)
110
- activestorage (= 6.0.3.2)
111
- activesupport (= 6.0.3.2)
112
- bundler (>= 1.3.0)
113
- railties (= 6.0.3.2)
106
+ rails (6.1.1)
107
+ actioncable (= 6.1.1)
108
+ actionmailbox (= 6.1.1)
109
+ actionmailer (= 6.1.1)
110
+ actionpack (= 6.1.1)
111
+ actiontext (= 6.1.1)
112
+ actionview (= 6.1.1)
113
+ activejob (= 6.1.1)
114
+ activemodel (= 6.1.1)
115
+ activerecord (= 6.1.1)
116
+ activestorage (= 6.1.1)
117
+ activesupport (= 6.1.1)
118
+ bundler (>= 1.15.0)
119
+ railties (= 6.1.1)
114
120
  sprockets-rails (>= 2.0.0)
115
121
  rails-dom-testing (2.0.3)
116
122
  activesupport (>= 4.2.0)
117
123
  nokogiri (>= 1.6)
118
124
  rails-html-sanitizer (1.3.0)
119
125
  loofah (~> 2.3)
120
- railties (6.0.3.2)
121
- actionpack (= 6.0.3.2)
122
- activesupport (= 6.0.3.2)
126
+ railties (6.1.1)
127
+ actionpack (= 6.1.1)
128
+ activesupport (= 6.1.1)
123
129
  method_source
124
130
  rake (>= 0.8.7)
125
- thor (>= 0.20.3, < 2.0)
131
+ thor (~> 1.0)
126
132
  rake (13.0.1)
127
133
  sprockets (4.0.2)
128
134
  concurrent-ruby (~> 1.0)
129
135
  rack (> 1, < 3)
130
- sprockets-rails (3.2.1)
136
+ sprockets-rails (3.2.2)
131
137
  actionpack (>= 4.0)
132
138
  activesupport (>= 4.0)
133
139
  sprockets (>= 3.0.0)
134
140
  thor (1.0.1)
135
- thread_safe (0.3.6)
136
- tzinfo (1.2.7)
137
- thread_safe (~> 0.1)
138
- websocket-driver (0.7.2)
141
+ tzinfo (2.0.4)
142
+ concurrent-ruby (~> 1.0)
143
+ websocket-driver (0.7.3)
139
144
  websocket-extensions (>= 0.1.0)
140
145
  websocket-extensions (0.1.5)
141
- zeitwerk (2.3.1)
146
+ zeitwerk (2.4.2)
142
147
 
143
148
  PLATFORMS
144
149
  ruby
@@ -2,7 +2,7 @@
2
2
  module PierLogging
3
3
  class Logger < Ougai::Logger
4
4
  include ActiveSupport::LoggerThreadSafeLevel
5
- include LoggerSilence
5
+ include ActiveSupport::LoggerSilence if defined?(ActiveSupport::LoggerSilence)
6
6
 
7
7
  def initialize(*args)
8
8
  super
@@ -44,7 +44,7 @@ module PierLogging
44
44
  env, status, type, body, starts_at, ends_at, _ = args
45
45
  request = Rack::Request.new(env)
46
46
  request_headers = get_request_headers_from_env(env)
47
- logger.info redact_hash({
47
+ logger.info redact_object({
48
48
  message: build_message_from_request(request),
49
49
  type: 'http',
50
50
  duration: ((ends_at - starts_at)*1000).to_i,
@@ -56,7 +56,8 @@ module PierLogging
56
56
  request: {
57
57
  headers: request_headers,
58
58
  href: request.url,
59
- body: parse_body(request.POST)
59
+ query_string: request.query_string,
60
+ body: parse_body(request.body)
60
61
  },
61
62
  response: {
62
63
  status: status,
@@ -77,7 +78,7 @@ module PierLogging
77
78
  headers = env.select { |k,v| k[0..4] == 'HTTP_'}.
78
79
  transform_keys { |k| k[5..-1].split('_').join('-').upcase }
79
80
 
80
- return redact_hash(headers, hide_request_headers, nil) if hide_request_headers.present?
81
+ return redact_object(headers, hide_request_headers, nil) if hide_request_headers.present?
81
82
 
82
83
  headers
83
84
  end
@@ -103,7 +104,7 @@ module PierLogging
103
104
  end
104
105
 
105
106
  def get_correlation_id(env, headers)
106
- PierLogging.request_logger_configuration.correlation_id_getter(env, headers) || headers['X-CORRELATION-ID']
107
+ PierLogging.request_logger_configuration.correlation_id_getter.call(env, headers) || headers['X-CORRELATION-ID']
107
108
  end
108
109
 
109
110
  def parse_body(body)
@@ -119,13 +120,35 @@ module PierLogging
119
120
  body
120
121
  end
121
122
 
123
+ def redact_object(obj, replace_keys = REDACT_REPLACE_KEYS, replace_by = REDACT_REPLACE_BY)
124
+ if obj === Array
125
+ redact_array(obj, replace_keys, replace_by)
126
+ elsif obj === Hash
127
+ redact_hash(obj, replace_keys, replace_by)
128
+ elsif obj.respond_to?(:to_hash)
129
+ redact_hash(obj.to_hash, replace_keys, replace_by)
130
+ else
131
+ obj
132
+ end
133
+ end
134
+
135
+ def redact_array(arr, replace_keys = REDACT_REPLACE_KEYS, replace_by = REDACT_REPLACE_BY)
136
+ raise StandardError, 'Could not redact_array for non-array objects' unless arr.is_a? Array
137
+ arr.map { |el| redact_object(el, replace_keys, replace_by) }
138
+ end
139
+
122
140
  def redact_hash(hash, replace_keys = REDACT_REPLACE_KEYS, replace_by = REDACT_REPLACE_BY)
123
- hash.traverse do |k,v|
141
+ raise StandardError, 'Could not redact_hash for non-hash objects' unless hash.is_a? Hash
142
+ hash.traverse do |k,v|
124
143
  should_redact = replace_keys.any?{ |regex| k =~regex }
125
144
  if (should_redact)
126
145
  [k, replace_by]
127
146
  else
128
- [k, v]
147
+ case v
148
+ when Array then [k, redact_array(v, replace_keys, replace_by)]
149
+ else
150
+ [k, v]
151
+ end
129
152
  end
130
153
  end
131
154
  end
@@ -1,3 +1,3 @@
1
1
  module PierLogging
2
- VERSION = "0.2.2"
2
+ VERSION = "0.3.1"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pier_logging
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.2
4
+ version: 0.3.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mauricio Banduk
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2020-08-14 00:00:00.000000000 Z
11
+ date: 2021-01-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: ougai