heavylog 0.0.21 → 0.0.24

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: 1e5698a7bfa3d9476d9b35f0a0da99a7faeeb230df8889599cf343b017745488
4
- data.tar.gz: 74d24b9be2f75463929bc5de1cb076fca87cb7b707a7123474a95682b3899e4a
3
+ metadata.gz: 9fe27830787b48899c66a075f26ea2d6dc3974002cd062a27b7f49ab86693bd5
4
+ data.tar.gz: c837bb8c2003016d7a954a9de2bbc85bc15fa12cfc1a5fc54f85ffc8b7f6510b
5
5
  SHA512:
6
- metadata.gz: 1dde2fc6a5912a2345729bd7150d1a6c39b55ab4f90800ee2cbe61acb3f351c978ecadea820981ba1cc94180140d8ddbab0f0f6890901c6251a906b2be9343a7
7
- data.tar.gz: b7a5930b2cba4fa6501798ac200978a5c172cda4af2b0d1dd55dc23bf0373edde9c722b1b3cbf658f68163d03adee190814f3d342bf621bf5d11c7eeab03dbaa
6
+ metadata.gz: 3d5b4e94fbfc8628f564f07402596d74a5162ecc3a355140f459a896d85e2e4e251522d0decd4296f2219e64019aa3a122418eb853c702f6ca2381789d301e12
7
+ data.tar.gz: 39bcf79abfa483de45202ecd82f75e4f65be86c9ab91d0c497aa51dae271768fb3a3b63be53747b2b7c0caa99c358374bacd88be04ef711358a82f1da832e76a
@@ -12,7 +12,7 @@ jobs:
12
12
  - name: Set up Ruby
13
13
  uses: ruby/setup-ruby@v1
14
14
  with:
15
- ruby-version: 3.0.1
15
+ ruby-version: 3.1.1
16
16
 
17
17
  - uses: actions/cache@v1
18
18
  with:
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- heavylog (0.0.21)
4
+ heavylog (0.0.24)
5
5
  actionpack (>= 5)
6
6
  activesupport (>= 5)
7
7
  railties (>= 5)
@@ -10,93 +10,93 @@ PATH
10
10
  GEM
11
11
  remote: https://rubygems.org/
12
12
  specs:
13
- actionpack (6.1.3.2)
14
- actionview (= 6.1.3.2)
15
- activesupport (= 6.1.3.2)
16
- rack (~> 2.0, >= 2.0.9)
13
+ actionpack (7.0.3.1)
14
+ actionview (= 7.0.3.1)
15
+ activesupport (= 7.0.3.1)
16
+ rack (~> 2.0, >= 2.2.0)
17
17
  rack-test (>= 0.6.3)
18
18
  rails-dom-testing (~> 2.0)
19
19
  rails-html-sanitizer (~> 1.0, >= 1.2.0)
20
- actionview (6.1.3.2)
21
- activesupport (= 6.1.3.2)
20
+ actionview (7.0.3.1)
21
+ activesupport (= 7.0.3.1)
22
22
  builder (~> 3.1)
23
23
  erubi (~> 1.4)
24
24
  rails-dom-testing (~> 2.0)
25
25
  rails-html-sanitizer (~> 1.1, >= 1.2.0)
26
- activesupport (6.1.3.2)
26
+ activesupport (7.0.3.1)
27
27
  concurrent-ruby (~> 1.0, >= 1.0.2)
28
28
  i18n (>= 1.6, < 2)
29
29
  minitest (>= 5.1)
30
30
  tzinfo (~> 2.0)
31
- zeitwerk (~> 2.3)
32
31
  ast (2.4.2)
33
- backport (1.1.2)
34
- benchmark (0.1.1)
32
+ backport (1.2.0)
33
+ benchmark (0.2.0)
35
34
  builder (3.2.4)
36
- concurrent-ruby (1.1.8)
35
+ concurrent-ruby (1.1.10)
37
36
  connection_pool (2.2.5)
38
37
  crass (1.0.6)
39
- diff-lcs (1.4.4)
40
- docile (1.3.5)
38
+ diff-lcs (1.5.0)
39
+ docile (1.4.0)
41
40
  e2mmap (0.1.0)
42
41
  erubi (1.10.0)
43
- i18n (1.8.10)
42
+ i18n (1.11.0)
44
43
  concurrent-ruby (~> 1.0)
45
44
  jaro_winkler (1.5.4)
46
- json (2.5.1)
47
- kramdown (2.3.1)
45
+ json (2.6.2)
46
+ kramdown (2.4.0)
48
47
  rexml
49
48
  kramdown-parser-gfm (1.1.0)
50
49
  kramdown (~> 2.0)
51
- loofah (2.9.1)
50
+ loofah (2.18.0)
52
51
  crass (~> 1.0.2)
53
52
  nokogiri (>= 1.5.9)
54
53
  method_source (1.0.0)
55
- mini_portile2 (2.5.1)
56
- minitest (5.14.4)
57
- nokogiri (1.11.3)
58
- mini_portile2 (~> 2.5.0)
54
+ mini_portile2 (2.8.0)
55
+ minitest (5.16.2)
56
+ nokogiri (1.13.7)
57
+ mini_portile2 (~> 2.8.0)
59
58
  racc (~> 1.4)
60
- parallel (1.20.1)
61
- parser (3.0.1.0)
59
+ parallel (1.22.1)
60
+ parser (3.1.2.0)
62
61
  ast (~> 2.4.1)
63
- racc (1.5.2)
64
- rack (2.2.3)
65
- rack-test (1.1.0)
66
- rack (>= 1.0, < 3)
62
+ racc (1.6.0)
63
+ rack (2.2.4)
64
+ rack-test (2.0.2)
65
+ rack (>= 1.3)
67
66
  rails-dom-testing (2.0.3)
68
67
  activesupport (>= 4.2.0)
69
68
  nokogiri (>= 1.6)
70
- rails-html-sanitizer (1.3.0)
69
+ rails-html-sanitizer (1.4.3)
71
70
  loofah (~> 2.3)
72
- railties (6.1.3.2)
73
- actionpack (= 6.1.3.2)
74
- activesupport (= 6.1.3.2)
71
+ railties (7.0.3.1)
72
+ actionpack (= 7.0.3.1)
73
+ activesupport (= 7.0.3.1)
75
74
  method_source
76
- rake (>= 0.8.7)
75
+ rake (>= 12.2)
77
76
  thor (~> 1.0)
78
- rainbow (3.0.0)
79
- rake (13.0.3)
80
- redis (4.2.5)
81
- regexp_parser (2.1.1)
82
- request_store (1.5.0)
77
+ zeitwerk (~> 2.5)
78
+ rainbow (3.1.1)
79
+ rake (13.0.6)
80
+ redis (4.7.1)
81
+ regexp_parser (2.5.0)
82
+ request_store (1.5.1)
83
83
  rack (>= 1.4)
84
- reverse_markdown (2.0.0)
84
+ reverse_markdown (2.1.1)
85
85
  nokogiri
86
86
  rexml (3.2.5)
87
- rspec (3.10.0)
88
- rspec-core (~> 3.10.0)
89
- rspec-expectations (~> 3.10.0)
90
- rspec-mocks (~> 3.10.0)
91
- rspec-core (3.10.1)
92
- rspec-support (~> 3.10.0)
93
- rspec-expectations (3.10.1)
87
+ rspec (3.11.0)
88
+ rspec-core (~> 3.11.0)
89
+ rspec-expectations (~> 3.11.0)
90
+ rspec-mocks (~> 3.11.0)
91
+ rspec-core (3.11.0)
92
+ rspec-support (~> 3.11.0)
93
+ rspec-expectations (3.11.0)
94
94
  diff-lcs (>= 1.2.0, < 2.0)
95
- rspec-support (~> 3.10.0)
96
- rspec-mocks (3.10.2)
95
+ rspec-support (~> 3.11.0)
96
+ rspec-mocks (3.11.1)
97
97
  diff-lcs (>= 1.2.0, < 2.0)
98
- rspec-support (~> 3.10.0)
99
- rspec-support (3.10.2)
98
+ rspec-support (~> 3.11.0)
99
+ rspec-support (3.11.0)
100
100
  rubocop (0.93.1)
101
101
  parallel (~> 1.10)
102
102
  parser (>= 2.7.1.5)
@@ -106,12 +106,12 @@ GEM
106
106
  rubocop-ast (>= 0.6.0)
107
107
  ruby-progressbar (~> 1.7)
108
108
  unicode-display_width (>= 1.4.0, < 2.0)
109
- rubocop-ast (1.4.1)
110
- parser (>= 2.7.1.5)
109
+ rubocop-ast (1.19.1)
110
+ parser (>= 3.1.1.0)
111
111
  rubocop-performance (1.5.2)
112
112
  rubocop (>= 0.71.0)
113
113
  ruby-progressbar (1.11.0)
114
- sidekiq (6.2.1)
114
+ sidekiq (6.5.1)
115
115
  connection_pool (>= 2.2.2)
116
116
  rack (~> 2.0)
117
117
  redis (>= 4.2.0)
@@ -120,10 +120,11 @@ GEM
120
120
  json (>= 1.8, < 3)
121
121
  simplecov-html (~> 0.10.0)
122
122
  simplecov-html (0.10.2)
123
- solargraph (0.40.4)
124
- backport (~> 1.1)
123
+ solargraph (0.45.0)
124
+ backport (~> 1.2)
125
125
  benchmark
126
126
  bundler (>= 1.17.2)
127
+ diff-lcs (~> 1.4)
127
128
  e2mmap
128
129
  jaro_winkler (~> 1.5)
129
130
  kramdown (~> 2.3)
@@ -134,13 +135,15 @@ GEM
134
135
  thor (~> 1.0)
135
136
  tilt (~> 2.0)
136
137
  yard (~> 0.9, >= 0.9.24)
137
- thor (1.1.0)
138
+ thor (1.2.1)
138
139
  tilt (2.0.10)
139
140
  tzinfo (2.0.4)
140
141
  concurrent-ruby (~> 1.0)
141
- unicode-display_width (1.7.0)
142
- yard (0.9.26)
143
- zeitwerk (2.4.2)
142
+ unicode-display_width (1.8.0)
143
+ webrick (1.7.0)
144
+ yard (0.9.28)
145
+ webrick (~> 1.7.0)
146
+ zeitwerk (2.6.0)
144
147
 
145
148
  PLATFORMS
146
149
  ruby
@@ -16,7 +16,9 @@ module Heavylog
16
16
  "status" => "http.response.status_code",
17
17
  "location" => "http.response.location",
18
18
  "ip" => "source.address",
19
+ "host" => "url.domain",
19
20
  "path" => "url.original",
21
+ "user_agent" => "user_agent.original",
20
22
  "controller" => "heavylog.controller",
21
23
  "action" => "heavylog.action",
22
24
  "unpermitted_params" => "heavylog.unpermitted_params",
@@ -28,7 +30,7 @@ module Heavylog
28
30
 
29
31
  def call(data)
30
32
  ECS_MAP.each do |original, correct|
31
- dig_set(data, correct.split("."), data.delete(original)) if data[original]
33
+ dig_set(data, correct.split("."), data.delete(original)) if data.key?(original)
32
34
  end
33
35
 
34
36
  dig_set(data, %w[event module], "heavylog")
@@ -31,7 +31,7 @@ module Heavylog
31
31
  data.merge!(extract_runtimes(event, payload))
32
32
  data.merge!(extract_location)
33
33
  data.merge!(extract_unpermitted_params)
34
- data.merge!(extract_referrer(payload))
34
+ data.merge!(extract_request_data(payload))
35
35
  data.merge!(custom_options(event))
36
36
  end
37
37
 
@@ -60,11 +60,11 @@ module Heavylog
60
60
  end
61
61
 
62
62
  def extract_status(payload)
63
- if (status = payload[:status])
64
- { status: status.to_i }
65
- elsif (error = payload[:exception])
63
+ if (error = payload[:exception])
66
64
  exception, message = error
67
- { status: get_error_status_code(exception), error: "#{exception}: #{message}" }
65
+ { status: payload[:status] || get_error_status_code(exception), error: "#{exception}: #{message}" }
66
+ elsif (status = payload[:status])
67
+ { status: status.to_i }
68
68
  else
69
69
  { status: 0 }
70
70
  end
@@ -103,9 +103,15 @@ module Heavylog
103
103
  { unpermitted_params: unpermitted_params }
104
104
  end
105
105
 
106
- def extract_referrer(payload)
107
- if payload[:request].is_a?(ActionDispatch::Request) && payload[:request].referrer
108
- return { referrer: payload[:request].referrer }
106
+ def extract_request_data(payload)
107
+ if payload[:request].is_a?(ActionDispatch::Request)
108
+ data = {}
109
+
110
+ data[:referrer] = payload[:request].referrer if payload[:request].referrer
111
+ data[:host] = payload[:request].host
112
+ data[:user_agent] = payload[:request].user_agent
113
+
114
+ return data
109
115
  end
110
116
 
111
117
  {}
@@ -11,7 +11,9 @@ module Heavylog
11
11
  end
12
12
 
13
13
  def call(env)
14
- ignore = @sprockets && env["PATH_INFO"] =~ @assets_regex
14
+ ignore = (@sprockets && env["PATH_INFO"] =~ @assets_regex) ||
15
+ (Heavylog.ignore_path && env["PATH_INFO"] =~ Heavylog.ignore_path)
16
+
15
17
  unless ignore
16
18
  request = ActionDispatch::Request.new(env)
17
19
  RequestStore.store[:heavylog_request_id] = request.uuid
@@ -7,6 +7,7 @@ module Heavylog
7
7
  config.heavylog.path = "log/heavylog.log"
8
8
  config.heavylog.message_limit = 1024 * 1024 * 50 # 50MB
9
9
  config.heavylog.log_sidekiq = false
10
+ config.heavylog.ignore_path = nil
10
11
  config.heavylog.error_handler = lambda { |e|
11
12
  Kernel.puts "HeavyLog: Error writing to log: #{e.class}: #{e.message}\n #{e.backtrace.join("\n ")}"
12
13
  }
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Heavylog
4
- VERSION = "0.0.21"
4
+ VERSION = "0.0.24"
5
5
  end
data/lib/heavylog.rb CHANGED
@@ -17,7 +17,7 @@ module Heavylog
17
17
  TRUNCATION = "[TRUNCATED]"
18
18
  ANSI_REGEX = /\e\[(\d+)m/.freeze
19
19
 
20
- mattr_accessor :logger, :application, :formatter, :log_level
20
+ mattr_accessor :logger, :application, :formatter, :log_level, :ignore_path
21
21
 
22
22
  def setup(app)
23
23
  self.application = app
@@ -43,6 +43,7 @@ module Heavylog
43
43
 
44
44
  Heavylog.formatter = config.formatter || Heavylog::Formatters::Raw.new
45
45
  Heavylog.log_level = config.log_level || :info
46
+ Heavylog.ignore_path = config.ignore_path || nil
46
47
  end
47
48
 
48
49
  def attach_to_action_controller
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: heavylog
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.21
4
+ version: 0.0.24
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kristjan Rang
8
- autorequire:
8
+ autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2021-05-18 00:00:00.000000000 Z
11
+ date: 2022-07-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -214,7 +214,7 @@ homepage: https://github.com/krisrang/heavylog
214
214
  licenses:
215
215
  - MIT
216
216
  metadata: {}
217
- post_install_message:
217
+ post_install_message:
218
218
  rdoc_options: []
219
219
  require_paths:
220
220
  - lib
@@ -229,8 +229,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
229
229
  - !ruby/object:Gem::Version
230
230
  version: '0'
231
231
  requirements: []
232
- rubygems_version: 3.2.15
233
- signing_key:
232
+ rubygems_version: 3.3.7
233
+ signing_key:
234
234
  specification_version: 4
235
235
  summary: Format all Rails logging per request
236
236
  test_files: []