pier_logging 0.2.3 → 0.3.2

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: a7e62fec86c0128b538d981f3920a29ef7facca185c9f0a2e57b05025b01fdc9
4
- data.tar.gz: 9e9823722a20e9b6279e086513a30ca948fa87bba2ed776e5b2df39023133c38
3
+ metadata.gz: f3b5d51eccb3353d9b1e898eb5c6f6d5d14dedcb183df51c7ed6300554e702f9
4
+ data.tar.gz: 55a389c152833b3b94889af6fecaddc73682d33a5b48ac495fdf414f7e8886fe
5
5
  SHA512:
6
- metadata.gz: 878039658c28b40809de6cff417fafa7c25b63852b9f1a41f1e5513c4266f5fe430f65d452315b5973c2764678092492ad81de6738bb8667df6544504747a47d
7
- data.tar.gz: 7488c60cf4dbec7507853be535cb7639c16035d6b87102a577cd88b81450f738da9a672c1b10552cc709b1d71bfa2b38b6f04cc31b65ba6290209280e689c9f2
6
+ metadata.gz: 1246e42cf2aa2632506cb52aa90159998582f80ed89dda9915834abbff04f726d84fcd819c99dcf9cc0a73d56db03ee0ba597ba29fafa547028ab3f52f75e1b5
7
+ data.tar.gz: a4d3294e81e52f535a08f8fe883efdcf93acc8f98d27e12c879290db862dcb748458adadb4e7541b5cafcded08e99b74a681d820106a8c7dc9567260124ea2b0
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- pier_logging (0.1.7)
4
+ pier_logging (0.3.1)
5
5
  awesome_print
6
6
  facets
7
7
  ougai
@@ -10,135 +10,138 @@ 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.3.1)
14
+ actionpack (= 6.1.3.1)
15
+ activesupport (= 6.1.3.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.3.1)
19
+ actionpack (= 6.1.3.1)
20
+ activejob (= 6.1.3.1)
21
+ activerecord (= 6.1.3.1)
22
+ activestorage (= 6.1.3.1)
23
+ activesupport (= 6.1.3.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.3.1)
26
+ actionpack (= 6.1.3.1)
27
+ actionview (= 6.1.3.1)
28
+ activejob (= 6.1.3.1)
29
+ activesupport (= 6.1.3.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.3.1)
33
+ actionview (= 6.1.3.1)
34
+ activesupport (= 6.1.3.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.3.1)
40
+ actionpack (= 6.1.3.1)
41
+ activerecord (= 6.1.3.1)
42
+ activestorage (= 6.1.3.1)
43
+ activesupport (= 6.1.3.1)
42
44
  nokogiri (>= 1.8.5)
43
- actionview (6.0.3.2)
44
- activesupport (= 6.0.3.2)
45
+ actionview (6.1.3.1)
46
+ activesupport (= 6.1.3.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.3.1)
52
+ activesupport (= 6.1.3.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)
61
- marcel (~> 0.3.1)
62
- activesupport (6.0.3.2)
54
+ activemodel (6.1.3.1)
55
+ activesupport (= 6.1.3.1)
56
+ activerecord (6.1.3.1)
57
+ activemodel (= 6.1.3.1)
58
+ activesupport (= 6.1.3.1)
59
+ activestorage (6.1.3.1)
60
+ actionpack (= 6.1.3.1)
61
+ activejob (= 6.1.3.1)
62
+ activerecord (= 6.1.3.1)
63
+ activesupport (= 6.1.3.1)
64
+ marcel (~> 1.0.0)
65
+ mini_mime (~> 1.0.2)
66
+ activesupport (6.1.3.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
- awesome_print (1.8.0)
68
+ i18n (>= 1.6, < 2)
69
+ minitest (>= 5.1)
70
+ tzinfo (~> 2.0)
71
+ zeitwerk (~> 2.3)
72
+ awesome_print (1.9.2)
69
73
  builder (3.2.4)
70
74
  byebug (11.1.3)
71
- concurrent-ruby (1.1.6)
75
+ concurrent-ruby (1.1.8)
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.10)
78
82
  concurrent-ruby (~> 1.0)
79
- loofah (2.6.0)
83
+ loofah (2.9.1)
80
84
  crass (~> 1.0.2)
81
85
  nokogiri (>= 1.5.9)
82
86
  mail (2.7.1)
83
87
  mini_mime (>= 0.1.1)
84
- marcel (0.3.3)
85
- mimemagic (~> 0.3.2)
88
+ marcel (1.0.1)
86
89
  method_source (1.0.0)
87
- mimemagic (0.3.5)
88
- mini_mime (1.0.2)
89
- mini_portile2 (2.4.0)
90
- 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
- ougai (1.8.5)
90
+ mini_mime (1.0.3)
91
+ mini_portile2 (2.5.0)
92
+ minitest (5.14.4)
93
+ nio4r (2.5.7)
94
+ nokogiri (1.11.3)
95
+ mini_portile2 (~> 2.5.0)
96
+ racc (~> 1.4)
97
+ oj (3.11.3)
98
+ ougai (2.0.0)
96
99
  oj (~> 3.10)
100
+ racc (1.5.2)
97
101
  rack (2.2.3)
98
102
  rack-test (1.1.0)
99
103
  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)
104
+ rails (6.1.3.1)
105
+ actioncable (= 6.1.3.1)
106
+ actionmailbox (= 6.1.3.1)
107
+ actionmailer (= 6.1.3.1)
108
+ actionpack (= 6.1.3.1)
109
+ actiontext (= 6.1.3.1)
110
+ actionview (= 6.1.3.1)
111
+ activejob (= 6.1.3.1)
112
+ activemodel (= 6.1.3.1)
113
+ activerecord (= 6.1.3.1)
114
+ activestorage (= 6.1.3.1)
115
+ activesupport (= 6.1.3.1)
116
+ bundler (>= 1.15.0)
117
+ railties (= 6.1.3.1)
114
118
  sprockets-rails (>= 2.0.0)
115
119
  rails-dom-testing (2.0.3)
116
120
  activesupport (>= 4.2.0)
117
121
  nokogiri (>= 1.6)
118
122
  rails-html-sanitizer (1.3.0)
119
123
  loofah (~> 2.3)
120
- railties (6.0.3.2)
121
- actionpack (= 6.0.3.2)
122
- activesupport (= 6.0.3.2)
124
+ railties (6.1.3.1)
125
+ actionpack (= 6.1.3.1)
126
+ activesupport (= 6.1.3.1)
123
127
  method_source
124
128
  rake (>= 0.8.7)
125
- thor (>= 0.20.3, < 2.0)
126
- rake (13.0.1)
129
+ thor (~> 1.0)
130
+ rake (13.0.3)
127
131
  sprockets (4.0.2)
128
132
  concurrent-ruby (~> 1.0)
129
133
  rack (> 1, < 3)
130
- sprockets-rails (3.2.1)
134
+ sprockets-rails (3.2.2)
131
135
  actionpack (>= 4.0)
132
136
  activesupport (>= 4.0)
133
137
  sprockets (>= 3.0.0)
134
- 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)
138
+ thor (1.1.0)
139
+ tzinfo (2.0.4)
140
+ concurrent-ruby (~> 1.0)
141
+ websocket-driver (0.7.3)
139
142
  websocket-extensions (>= 0.1.0)
140
143
  websocket-extensions (0.1.5)
141
- zeitwerk (2.3.1)
144
+ zeitwerk (2.4.2)
142
145
 
143
146
  PLATFORMS
144
147
  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
@@ -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.3"
2
+ VERSION = "0.3.2"
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.3
4
+ version: 0.3.2
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-17 00:00:00.000000000 Z
11
+ date: 2021-04-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: ougai