paul_bunyan 1.6.0 → 2.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (37) hide show
  1. checksums.yaml +4 -4
  2. data/Appraisals +7 -0
  3. data/Dockerfile +10 -15
  4. data/Jenkinsfile +34 -6
  5. data/Rakefile +4 -2
  6. data/docker-compose.override.yml.example +2 -2
  7. data/gemfiles/rails_6.1.gemfile +7 -0
  8. data/gemfiles/rails_6.1.gemfile.lock +185 -0
  9. data/gemfiles/rails_7.0.gemfile +7 -0
  10. data/gemfiles/rails_7.0.gemfile.lock +184 -0
  11. data/lib/paul_bunyan/json_formatter.rb +7 -7
  12. data/lib/paul_bunyan/log_relayer.rb +25 -9
  13. data/lib/paul_bunyan/metadata_logging.rb +6 -6
  14. data/lib/paul_bunyan/railtie/log_subscriber.rb +3 -1
  15. data/lib/paul_bunyan/railtie.rb +0 -1
  16. data/lib/paul_bunyan/version.rb +1 -1
  17. data/paul_bunyan.gemspec +2 -2
  18. data/spec/dummy/app/models/application_record.rb +3 -0
  19. data/spec/dummy/app/models/widget.rb +2 -0
  20. data/spec/dummy/config/application.rb +2 -3
  21. data/spec/dummy/config/environments/development.rb +0 -14
  22. data/spec/dummy/db/migrate/20230301183442_create_widgets.rb +10 -0
  23. data/spec/dummy/db/schema.rb +21 -0
  24. data/spec/lib/paul_bunyan/log_relayer_spec.rb +14 -10
  25. data/spec/lib/paul_bunyan/metadata_logging_spec.rb +6 -6
  26. data/spec/lib/paul_bunyan/railtie/log_subscriber_spec.rb +6 -2
  27. data/spec/lib/paul_bunyan/railtie_spec.rb +4 -4
  28. metadata +26 -26
  29. data/.travis.yml +0 -21
  30. data/lib/paul_bunyan/rails_ext/active_support_logger.rb +0 -11
  31. data/lib/paul_bunyan/rails_ext/instrumentation.rb +0 -41
  32. data/lib/paul_bunyan/rails_ext/rack_logger.rb +0 -24
  33. data/lib/paul_bunyan/rails_ext.rb +0 -8
  34. data/spec/dummy/config/initializers/assets.rb +0 -11
  35. data/spec/gemfiles/52.gemfile +0 -5
  36. data/spec/gemfiles/60.gemfile +0 -5
  37. data/spec/lib/paul_bunyan/rails_ext/instrumentation_spec.rb +0 -103
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 733bf0c476cf961dcccd7d662b8a9676eab037a3e75cdd6ce078c13079f490ee
4
- data.tar.gz: 66c62fcc45b6f1c944a4cd567e248523d8ac37dd9fb0b733344bfb2299538a6e
3
+ metadata.gz: 8124cabd60f88bd7b947af924e5b7adcabfb38c7cb85c987ec621144c05cd043
4
+ data.tar.gz: acd3be9fa8f323516fa818f59aa64c102ae7676d95f8fe9ebeacec04e2d495ad
5
5
  SHA512:
6
- metadata.gz: a89471e33536f06b7f950cf5632e938261807a1f456019285f4e24bb5ef38e52c95d864126082244e5dd862ead583364fba9529c0eb765e732e70426d7827dd9
7
- data.tar.gz: 248a005d21714b311ef81929a1c794875c9994d2c4bea7edfb1cf45b3d80e7db6c84dd878e417f7e9acaba9d8c3de01672e083c83431fd0601dd5fb1d5c81f6a
6
+ metadata.gz: 1ee0b7bcae84200e6b91db8add8088cacf4bb21e7f575ca1629ea0b1414741c07aeaf7e04f21d1222c236d1888e777b724c64b2f6c2adbb6e5802aa31774ad81
7
+ data.tar.gz: c8ce668c803ffaf3480565d1b54a3172a3455c11d489cd5b8bdd5c2a2b2047ce4d6c97b082e760a05f7bde0dc91817191b726f4defd2292949974c1fc1a07495
data/Appraisals ADDED
@@ -0,0 +1,7 @@
1
+ appraise 'rails-6.1' do
2
+ gem 'rails', '>= 6.1', '< 6.2'
3
+ end
4
+
5
+ appraise 'rails-7.0' do
6
+ gem 'rails', '>= 7.0', '< 7.1'
7
+ end
data/Dockerfile CHANGED
@@ -1,19 +1,14 @@
1
- FROM instructure/rvm
2
- MAINTAINER Instructure
1
+ ARG RUBY_VERSION=2.7
2
+ FROM ruby:${RUBY_VERSION}
3
3
 
4
- WORKDIR /usr/src/app
5
- RUN /bin/bash -l -c "rvm use --default 2.4"
4
+ WORKDIR /app
6
5
 
7
- COPY paul_bunyan.gemspec Gemfile /usr/src/app/
8
- COPY lib/paul_bunyan/version.rb /usr/src/app/lib/paul_bunyan/
6
+ RUN /bin/bash -lc "gem install bundler -v 2.3.26"
9
7
 
10
- USER root
11
- RUN chown -R docker:docker /usr/src/app
12
- USER docker
13
- RUN /bin/bash -l -c "bundle install"
8
+ ARG BUNDLE_GEMFILE
9
+ ENV BUNDLE_GEMFILE $BUNDLE_GEMFILE
14
10
 
15
- COPY . /usr/src/app
16
- USER root
17
- RUN chown -R docker:docker /usr/src/app/*
18
- USER docker
19
- CMD /bin/bash -l -c "wwtd --parallel"
11
+ RUN echo "gem: --no-document" >> ~/.gemrc
12
+
13
+ COPY . /app
14
+ RUN /bin/bash -lc "bundle install --jobs 5"
data/Jenkinsfile CHANGED
@@ -1,12 +1,40 @@
1
+ #! /usr/bin/env groovy
2
+
1
3
  pipeline {
2
- agent {
3
- label "docker"
4
+ agent none
5
+
6
+ environment {
7
+ // Make sure we're ignoring any override files that may be present
8
+ COMPOSE_FILE = "docker-compose.yml"
4
9
  }
10
+
5
11
  stages {
6
- stage('Build') {
7
- steps {
8
- ansiColor('xterm') {
9
- sh './build.sh'
12
+ stage('Test') {
13
+ matrix {
14
+ agent { label 'docker' }
15
+ axes {
16
+ axis {
17
+ name 'RUBY_VERSION'
18
+ values '2.7', '3.0', '3.1'
19
+ }
20
+ axis {
21
+ name 'RAILS_VERSION'
22
+ values '6.1', '7.0'
23
+ }
24
+ }
25
+ stages {
26
+ stage('Build') {
27
+ steps {
28
+ sh "docker-compose build --pull --build-arg RUBY_VERSION=${RUBY_VERSION} --build-arg BUNDLE_GEMFILE=gemfiles/rails_${RAILS_VERSION}.gemfile test"
29
+ sh 'docker-compose run --rm test bundle exec rake'
30
+ }
31
+ }
32
+ }
33
+
34
+ post {
35
+ cleanup {
36
+ sh 'docker-compose down --remove-orphans --rmi all'
37
+ }
10
38
  }
11
39
  }
12
40
  }
data/Rakefile CHANGED
@@ -3,7 +3,6 @@ begin
3
3
  rescue LoadError
4
4
  puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
5
5
  end
6
- require "wwtd/tasks"
7
6
  require 'rdoc/task'
8
7
 
9
8
  RDoc::Task.new(:rdoc) do |rdoc|
@@ -16,4 +15,7 @@ end
16
15
 
17
16
  Bundler::GemHelper.install_tasks
18
17
 
19
- task default: "wwtd"
18
+ require 'rspec/core/rake_task'
19
+ RSpec::Core::RakeTask.new
20
+
21
+ task default: %i[spec]
@@ -3,8 +3,8 @@ services:
3
3
  test:
4
4
  build: .
5
5
  volumes:
6
- - "./:/usr/src/app"
7
- - "gems:/home/docker/.rvm/gems/"
6
+ - .:/app
7
+ - bundle:/usr/local/bundle
8
8
 
9
9
  volumes:
10
10
  gems: {}
@@ -0,0 +1,7 @@
1
+ # This file was generated by Appraisal
2
+
3
+ source "https://rubygems.org"
4
+
5
+ gem "rails", ">= 6.1", "< 6.2"
6
+
7
+ gemspec path: "../"
@@ -0,0 +1,185 @@
1
+ PATH
2
+ remote: ..
3
+ specs:
4
+ paul_bunyan (2.1.0)
5
+ request_store
6
+
7
+ GEM
8
+ remote: https://rubygems.org/
9
+ specs:
10
+ actioncable (6.1.7.2)
11
+ actionpack (= 6.1.7.2)
12
+ activesupport (= 6.1.7.2)
13
+ nio4r (~> 2.0)
14
+ websocket-driver (>= 0.6.1)
15
+ actionmailbox (6.1.7.2)
16
+ actionpack (= 6.1.7.2)
17
+ activejob (= 6.1.7.2)
18
+ activerecord (= 6.1.7.2)
19
+ activestorage (= 6.1.7.2)
20
+ activesupport (= 6.1.7.2)
21
+ mail (>= 2.7.1)
22
+ actionmailer (6.1.7.2)
23
+ actionpack (= 6.1.7.2)
24
+ actionview (= 6.1.7.2)
25
+ activejob (= 6.1.7.2)
26
+ activesupport (= 6.1.7.2)
27
+ mail (~> 2.5, >= 2.5.4)
28
+ rails-dom-testing (~> 2.0)
29
+ actionpack (6.1.7.2)
30
+ actionview (= 6.1.7.2)
31
+ activesupport (= 6.1.7.2)
32
+ rack (~> 2.0, >= 2.0.9)
33
+ rack-test (>= 0.6.3)
34
+ rails-dom-testing (~> 2.0)
35
+ rails-html-sanitizer (~> 1.0, >= 1.2.0)
36
+ actiontext (6.1.7.2)
37
+ actionpack (= 6.1.7.2)
38
+ activerecord (= 6.1.7.2)
39
+ activestorage (= 6.1.7.2)
40
+ activesupport (= 6.1.7.2)
41
+ nokogiri (>= 1.8.5)
42
+ actionview (6.1.7.2)
43
+ activesupport (= 6.1.7.2)
44
+ builder (~> 3.1)
45
+ erubi (~> 1.4)
46
+ rails-dom-testing (~> 2.0)
47
+ rails-html-sanitizer (~> 1.1, >= 1.2.0)
48
+ activejob (6.1.7.2)
49
+ activesupport (= 6.1.7.2)
50
+ globalid (>= 0.3.6)
51
+ activemodel (6.1.7.2)
52
+ activesupport (= 6.1.7.2)
53
+ activerecord (6.1.7.2)
54
+ activemodel (= 6.1.7.2)
55
+ activesupport (= 6.1.7.2)
56
+ activestorage (6.1.7.2)
57
+ actionpack (= 6.1.7.2)
58
+ activejob (= 6.1.7.2)
59
+ activerecord (= 6.1.7.2)
60
+ activesupport (= 6.1.7.2)
61
+ marcel (~> 1.0)
62
+ mini_mime (>= 1.1.0)
63
+ activesupport (6.1.7.2)
64
+ concurrent-ruby (~> 1.0, >= 1.0.2)
65
+ i18n (>= 1.6, < 2)
66
+ minitest (>= 5.1)
67
+ tzinfo (~> 2.0)
68
+ zeitwerk (~> 2.3)
69
+ appraisal (2.4.1)
70
+ bundler
71
+ rake
72
+ thor (>= 0.14.0)
73
+ builder (3.2.4)
74
+ byebug (11.1.3)
75
+ concurrent-ruby (1.2.2)
76
+ crass (1.0.6)
77
+ date (3.3.3)
78
+ diff-lcs (1.5.0)
79
+ erubi (1.12.0)
80
+ globalid (1.1.0)
81
+ activesupport (>= 5.0)
82
+ i18n (1.12.0)
83
+ concurrent-ruby (~> 1.0)
84
+ loofah (2.19.1)
85
+ crass (~> 1.0.2)
86
+ nokogiri (>= 1.5.9)
87
+ mail (2.8.1)
88
+ mini_mime (>= 0.1.1)
89
+ net-imap
90
+ net-pop
91
+ net-smtp
92
+ marcel (1.0.2)
93
+ method_source (1.0.0)
94
+ mini_mime (1.1.2)
95
+ minitest (5.17.0)
96
+ net-imap (0.3.4)
97
+ date
98
+ net-protocol
99
+ net-pop (0.1.2)
100
+ net-protocol
101
+ net-protocol (0.2.1)
102
+ timeout
103
+ net-smtp (0.3.3)
104
+ net-protocol
105
+ nio4r (2.5.8)
106
+ nokogiri (1.14.2-aarch64-linux)
107
+ racc (~> 1.4)
108
+ racc (1.6.2)
109
+ rack (2.2.6.2)
110
+ rack-test (2.0.2)
111
+ rack (>= 1.3)
112
+ rails (6.1.7.2)
113
+ actioncable (= 6.1.7.2)
114
+ actionmailbox (= 6.1.7.2)
115
+ actionmailer (= 6.1.7.2)
116
+ actionpack (= 6.1.7.2)
117
+ actiontext (= 6.1.7.2)
118
+ actionview (= 6.1.7.2)
119
+ activejob (= 6.1.7.2)
120
+ activemodel (= 6.1.7.2)
121
+ activerecord (= 6.1.7.2)
122
+ activestorage (= 6.1.7.2)
123
+ activesupport (= 6.1.7.2)
124
+ bundler (>= 1.15.0)
125
+ railties (= 6.1.7.2)
126
+ sprockets-rails (>= 2.0.0)
127
+ rails-dom-testing (2.0.3)
128
+ activesupport (>= 4.2.0)
129
+ nokogiri (>= 1.6)
130
+ rails-html-sanitizer (1.5.0)
131
+ loofah (~> 2.19, >= 2.19.1)
132
+ railties (6.1.7.2)
133
+ actionpack (= 6.1.7.2)
134
+ activesupport (= 6.1.7.2)
135
+ method_source
136
+ rake (>= 12.2)
137
+ thor (~> 1.0)
138
+ rake (13.0.6)
139
+ request_store (1.5.1)
140
+ rack (>= 1.4)
141
+ rspec (3.12.0)
142
+ rspec-core (~> 3.12.0)
143
+ rspec-expectations (~> 3.12.0)
144
+ rspec-mocks (~> 3.12.0)
145
+ rspec-core (3.12.1)
146
+ rspec-support (~> 3.12.0)
147
+ rspec-expectations (3.12.2)
148
+ diff-lcs (>= 1.2.0, < 2.0)
149
+ rspec-support (~> 3.12.0)
150
+ rspec-mocks (3.12.3)
151
+ diff-lcs (>= 1.2.0, < 2.0)
152
+ rspec-support (~> 3.12.0)
153
+ rspec-support (3.12.0)
154
+ sprockets (4.2.0)
155
+ concurrent-ruby (~> 1.0)
156
+ rack (>= 2.2.4, < 4)
157
+ sprockets-rails (3.4.2)
158
+ actionpack (>= 5.2)
159
+ activesupport (>= 5.2)
160
+ sprockets (>= 3.0.0)
161
+ sqlite3 (1.6.1-aarch64-linux)
162
+ thor (1.2.1)
163
+ timeout (0.3.2)
164
+ tzinfo (2.0.6)
165
+ concurrent-ruby (~> 1.0)
166
+ websocket-driver (0.7.5)
167
+ websocket-extensions (>= 0.1.0)
168
+ websocket-extensions (0.1.5)
169
+ zeitwerk (2.6.7)
170
+
171
+ PLATFORMS
172
+ aarch64-linux
173
+
174
+ DEPENDENCIES
175
+ appraisal (~> 2.4.0)
176
+ bundler
177
+ byebug
178
+ paul_bunyan!
179
+ rails (>= 6.1, < 6.2)
180
+ rake
181
+ rspec
182
+ sqlite3
183
+
184
+ BUNDLED WITH
185
+ 2.2.23
@@ -0,0 +1,7 @@
1
+ # This file was generated by Appraisal
2
+
3
+ source "https://rubygems.org"
4
+
5
+ gem "rails", ">= 7.0", "< 7.1"
6
+
7
+ gemspec path: "../"
@@ -0,0 +1,184 @@
1
+ PATH
2
+ remote: ..
3
+ specs:
4
+ paul_bunyan (2.1.0)
5
+ request_store
6
+
7
+ GEM
8
+ remote: https://rubygems.org/
9
+ specs:
10
+ actioncable (7.0.4.2)
11
+ actionpack (= 7.0.4.2)
12
+ activesupport (= 7.0.4.2)
13
+ nio4r (~> 2.0)
14
+ websocket-driver (>= 0.6.1)
15
+ actionmailbox (7.0.4.2)
16
+ actionpack (= 7.0.4.2)
17
+ activejob (= 7.0.4.2)
18
+ activerecord (= 7.0.4.2)
19
+ activestorage (= 7.0.4.2)
20
+ activesupport (= 7.0.4.2)
21
+ mail (>= 2.7.1)
22
+ net-imap
23
+ net-pop
24
+ net-smtp
25
+ actionmailer (7.0.4.2)
26
+ actionpack (= 7.0.4.2)
27
+ actionview (= 7.0.4.2)
28
+ activejob (= 7.0.4.2)
29
+ activesupport (= 7.0.4.2)
30
+ mail (~> 2.5, >= 2.5.4)
31
+ net-imap
32
+ net-pop
33
+ net-smtp
34
+ rails-dom-testing (~> 2.0)
35
+ actionpack (7.0.4.2)
36
+ actionview (= 7.0.4.2)
37
+ activesupport (= 7.0.4.2)
38
+ rack (~> 2.0, >= 2.2.0)
39
+ rack-test (>= 0.6.3)
40
+ rails-dom-testing (~> 2.0)
41
+ rails-html-sanitizer (~> 1.0, >= 1.2.0)
42
+ actiontext (7.0.4.2)
43
+ actionpack (= 7.0.4.2)
44
+ activerecord (= 7.0.4.2)
45
+ activestorage (= 7.0.4.2)
46
+ activesupport (= 7.0.4.2)
47
+ globalid (>= 0.6.0)
48
+ nokogiri (>= 1.8.5)
49
+ actionview (7.0.4.2)
50
+ activesupport (= 7.0.4.2)
51
+ builder (~> 3.1)
52
+ erubi (~> 1.4)
53
+ rails-dom-testing (~> 2.0)
54
+ rails-html-sanitizer (~> 1.1, >= 1.2.0)
55
+ activejob (7.0.4.2)
56
+ activesupport (= 7.0.4.2)
57
+ globalid (>= 0.3.6)
58
+ activemodel (7.0.4.2)
59
+ activesupport (= 7.0.4.2)
60
+ activerecord (7.0.4.2)
61
+ activemodel (= 7.0.4.2)
62
+ activesupport (= 7.0.4.2)
63
+ activestorage (7.0.4.2)
64
+ actionpack (= 7.0.4.2)
65
+ activejob (= 7.0.4.2)
66
+ activerecord (= 7.0.4.2)
67
+ activesupport (= 7.0.4.2)
68
+ marcel (~> 1.0)
69
+ mini_mime (>= 1.1.0)
70
+ activesupport (7.0.4.2)
71
+ concurrent-ruby (~> 1.0, >= 1.0.2)
72
+ i18n (>= 1.6, < 2)
73
+ minitest (>= 5.1)
74
+ tzinfo (~> 2.0)
75
+ appraisal (2.4.1)
76
+ bundler
77
+ rake
78
+ thor (>= 0.14.0)
79
+ builder (3.2.4)
80
+ byebug (11.1.3)
81
+ concurrent-ruby (1.2.2)
82
+ crass (1.0.6)
83
+ date (3.3.3)
84
+ diff-lcs (1.5.0)
85
+ erubi (1.12.0)
86
+ globalid (1.1.0)
87
+ activesupport (>= 5.0)
88
+ i18n (1.12.0)
89
+ concurrent-ruby (~> 1.0)
90
+ loofah (2.19.1)
91
+ crass (~> 1.0.2)
92
+ nokogiri (>= 1.5.9)
93
+ mail (2.8.1)
94
+ mini_mime (>= 0.1.1)
95
+ net-imap
96
+ net-pop
97
+ net-smtp
98
+ marcel (1.0.2)
99
+ method_source (1.0.0)
100
+ mini_mime (1.1.2)
101
+ minitest (5.17.0)
102
+ net-imap (0.3.4)
103
+ date
104
+ net-protocol
105
+ net-pop (0.1.2)
106
+ net-protocol
107
+ net-protocol (0.2.1)
108
+ timeout
109
+ net-smtp (0.3.3)
110
+ net-protocol
111
+ nio4r (2.5.8)
112
+ nokogiri (1.14.2-aarch64-linux)
113
+ racc (~> 1.4)
114
+ racc (1.6.2)
115
+ rack (2.2.6.2)
116
+ rack-test (2.0.2)
117
+ rack (>= 1.3)
118
+ rails (7.0.4.2)
119
+ actioncable (= 7.0.4.2)
120
+ actionmailbox (= 7.0.4.2)
121
+ actionmailer (= 7.0.4.2)
122
+ actionpack (= 7.0.4.2)
123
+ actiontext (= 7.0.4.2)
124
+ actionview (= 7.0.4.2)
125
+ activejob (= 7.0.4.2)
126
+ activemodel (= 7.0.4.2)
127
+ activerecord (= 7.0.4.2)
128
+ activestorage (= 7.0.4.2)
129
+ activesupport (= 7.0.4.2)
130
+ bundler (>= 1.15.0)
131
+ railties (= 7.0.4.2)
132
+ rails-dom-testing (2.0.3)
133
+ activesupport (>= 4.2.0)
134
+ nokogiri (>= 1.6)
135
+ rails-html-sanitizer (1.5.0)
136
+ loofah (~> 2.19, >= 2.19.1)
137
+ railties (7.0.4.2)
138
+ actionpack (= 7.0.4.2)
139
+ activesupport (= 7.0.4.2)
140
+ method_source
141
+ rake (>= 12.2)
142
+ thor (~> 1.0)
143
+ zeitwerk (~> 2.5)
144
+ rake (13.0.6)
145
+ request_store (1.5.1)
146
+ rack (>= 1.4)
147
+ rspec (3.12.0)
148
+ rspec-core (~> 3.12.0)
149
+ rspec-expectations (~> 3.12.0)
150
+ rspec-mocks (~> 3.12.0)
151
+ rspec-core (3.12.1)
152
+ rspec-support (~> 3.12.0)
153
+ rspec-expectations (3.12.2)
154
+ diff-lcs (>= 1.2.0, < 2.0)
155
+ rspec-support (~> 3.12.0)
156
+ rspec-mocks (3.12.3)
157
+ diff-lcs (>= 1.2.0, < 2.0)
158
+ rspec-support (~> 3.12.0)
159
+ rspec-support (3.12.0)
160
+ sqlite3 (1.6.1-aarch64-linux)
161
+ thor (1.2.1)
162
+ timeout (0.3.2)
163
+ tzinfo (2.0.6)
164
+ concurrent-ruby (~> 1.0)
165
+ websocket-driver (0.7.5)
166
+ websocket-extensions (>= 0.1.0)
167
+ websocket-extensions (0.1.5)
168
+ zeitwerk (2.6.7)
169
+
170
+ PLATFORMS
171
+ aarch64-linux
172
+
173
+ DEPENDENCIES
174
+ appraisal (~> 2.4.0)
175
+ bundler
176
+ byebug
177
+ paul_bunyan!
178
+ rails (>= 7.0, < 7.1)
179
+ rake
180
+ rspec
181
+ sqlite3
182
+
183
+ BUNDLED WITH
184
+ 2.2.23
@@ -5,8 +5,8 @@ module PaulBunyan
5
5
  class JSONFormatter
6
6
  DATETIME_FORMAT = '%Y-%m-%dT%H:%M:%S.%3N'
7
7
 
8
- def add_metadata(metadata)
9
- current_metadata.merge!(metadata)
8
+ def add_metadata(metadata, **kw_metadata)
9
+ current_metadata.merge!(metadata).merge!(kw_metadata)
10
10
  end
11
11
 
12
12
  def call(severity, time, progname, msg)
@@ -63,8 +63,8 @@ module PaulBunyan
63
63
  end
64
64
  end
65
65
 
66
- def remove_metadata(metadata)
67
- metadata.each { |k, _| current_metadata.delete(k) }
66
+ def remove_metadata(metadata = {}, **kw_metadata)
67
+ (metadata.keys + kw_metadata.keys).each { |k| current_metadata.delete(k) }
68
68
  end
69
69
 
70
70
  def tagged(*tags)
@@ -74,11 +74,11 @@ module PaulBunyan
74
74
  pop_tags(clean_tags.size)
75
75
  end
76
76
 
77
- def with_metadata(consumer_metadata)
78
- add_metadata(consumer_metadata)
77
+ def with_metadata(consumer_metadata = {}, **kw_metadata)
78
+ add_metadata(consumer_metadata, **kw_metadata)
79
79
  yield
80
80
  ensure
81
- remove_metadata(consumer_metadata)
81
+ remove_metadata(consumer_metadata, **kw_metadata)
82
82
  end
83
83
 
84
84
  private
@@ -34,6 +34,11 @@ module PaulBunyan
34
34
 
35
35
  def add_logger(logger)
36
36
  loggers.push(logger)
37
+
38
+ # Appease rails checking if logger already writes to stdout
39
+ if loggers.length == 1
40
+ @logdev = loggers[0].instance_variable_get(:@logdev)
41
+ end
37
42
  logger
38
43
  end
39
44
 
@@ -140,8 +145,8 @@ module PaulBunyan
140
145
  pop_tags(new_tags.size)
141
146
  end
142
147
 
143
- def add_metadata(metadata)
144
- messaging_loggers(:add_metadata, metadata)
148
+ def add_metadata(metadata = {}, **kw_metadata)
149
+ messaging_loggers(:add_metadata, metadata, **kw_metadata)
145
150
  end
146
151
 
147
152
  def clear_metadata!
@@ -158,15 +163,15 @@ module PaulBunyan
158
163
  end
159
164
  end
160
165
 
161
- def remove_metadata(metadata)
162
- messaging_loggers(:remove_metadata, metadata)
166
+ def remove_metadata(metadata = {}, **kw_metadata)
167
+ messaging_loggers(:remove_metadata, metadata, **kw_metadata)
163
168
  end
164
169
 
165
- def with_metadata(metadata)
166
- add_metadata(metadata)
170
+ def with_metadata(metadata = {}, **kw_metadata)
171
+ add_metadata(metadata, **kw_metadata)
167
172
  yield
168
173
  ensure
169
- remove_metadata(metadata)
174
+ remove_metadata(metadata, **kw_metadata)
170
175
  end
171
176
 
172
177
  private
@@ -181,8 +186,19 @@ module PaulBunyan
181
186
  end
182
187
  end
183
188
 
184
- def messaging_loggers(required_method, *args)
185
- loggers.each { |l| l.public_send(required_method, *args) if l.respond_to?(required_method) }
189
+ def messaging_loggers(required_method, *args, **kwargs)
190
+ loggers.each do |l|
191
+ next unless l.respond_to?(required_method)
192
+
193
+ # TODO remove this if and just always use the second branch once we only support
194
+ # ruby 3.0+ (and remove 2.7). Only matters for matchers in specs that natively
195
+ # work correctly on ruby 3.0
196
+ if kwargs.empty?
197
+ l.public_send(required_method, *args)
198
+ else
199
+ l.public_send(required_method, *args, **kwargs)
200
+ end
201
+ end
186
202
  nil
187
203
  end
188
204
  end
@@ -4,20 +4,20 @@ module PaulBunyan
4
4
  formatter.clear_metadata! if formatter.respond_to?(:clear_metadata!)
5
5
  end
6
6
 
7
- def with_metadata(metadata)
7
+ def with_metadata(metadata = {}, **kw_metadata)
8
8
  if formatter.respond_to?(:with_metadata)
9
- formatter.with_metadata(metadata) { yield self }
9
+ formatter.with_metadata(metadata, **kw_metadata) { yield self }
10
10
  else
11
11
  yield self
12
12
  end
13
13
  end
14
14
 
15
- def add_metadata(metadata)
16
- formatter.add_metadata(metadata) if formatter.respond_to?(:add_metadata)
15
+ def add_metadata(metadata = {}, **kw_metadata)
16
+ formatter.add_metadata(metadata, **kw_metadata) if formatter.respond_to?(:add_metadata)
17
17
  end
18
18
 
19
- def remove_metadata(metadata)
20
- formatter.remove_metadata(metadata) if formatter.respond_to?(:remove_metadata)
19
+ def remove_metadata(metadata = {}, **kw_metadata)
20
+ formatter.remove_metadata(metadata, **kw_metadata) if formatter.respond_to?(:remove_metadata)
21
21
  end
22
22
 
23
23
  def current_metadata
@@ -89,12 +89,14 @@ module PaulBunyan
89
89
  # the log line
90
90
  #
91
91
  # @param event [ActiveSupport::Notifications::Event]
92
- ACTION_PAYLOAD_KEYS = [:method, :controller, :action, :format, :path, :request_id, :ip, :status, :view_runtime, :db_runtime]
92
+ ACTION_PAYLOAD_KEYS = [:method, :controller, :action, :format, :path, :status, :view_runtime, :db_runtime]
93
93
  action_controller_event def process_action(event)
94
94
  payload = event.payload
95
95
  ACTION_PAYLOAD_KEYS.each do |attr|
96
96
  aggregator[attr] = payload[attr]
97
97
  end
98
+ aggregator[:ip] = payload[:request].ip
99
+ aggregator[:request_id] = payload[:request].env['action_dispatch.request_id']
98
100
  aggregator.params = payload[:params].except(*INTERNAL_PARAMS)
99
101
 
100
102
  logger.info { aggregator_without_nils }
@@ -1,4 +1,3 @@
1
- require 'paul_bunyan/rails_ext'
2
1
  require 'paul_bunyan/railtie/log_subscriber'
3
2
  require 'action_controller/log_subscriber'
4
3
  require 'action_view/log_subscriber'
@@ -1,3 +1,3 @@
1
1
  module PaulBunyan
2
- VERSION = '1.6.0'
2
+ VERSION = '2.1.0'
3
3
  end
data/paul_bunyan.gemspec CHANGED
@@ -20,11 +20,11 @@ Gem::Specification.new do |spec|
20
20
 
21
21
  spec.add_dependency 'request_store'
22
22
 
23
+ spec.add_development_dependency 'appraisal', '~> 2.4.0'
23
24
  spec.add_development_dependency 'bundler'
24
25
  spec.add_development_dependency 'rake'
25
26
  spec.add_development_dependency 'rspec'
26
- spec.add_development_dependency 'wwtd'
27
- spec.add_development_dependency 'rails', '>= 5.2'
27
+ spec.add_development_dependency 'rails', '>= 6.1'
28
28
  spec.add_development_dependency 'sqlite3'
29
29
  spec.add_development_dependency 'byebug'
30
30
  end
@@ -0,0 +1,3 @@
1
+ class ApplicationRecord < ActiveRecord::Base
2
+ self.abstract_class = true
3
+ end