effective_logging 3.0.7 → 3.0.12

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: dc9fced444e21c7fe1cdfc6eefbb7a4a1c5aefde46e660c80ea8e556e4811a53
4
- data.tar.gz: '02657769444b4e41d0fd0fa0ecd1d083aa5e60b7ba49df2f64be18d70e434404'
3
+ metadata.gz: 2898e7d8542c2b5c528242611aa2e80becf21097da0e71506e4ca205c0169933
4
+ data.tar.gz: edad3789ae84819c00bd87b507314f1dc7abe79d75809249b48ad53f28799ffa
5
5
  SHA512:
6
- metadata.gz: 01efee520769124bc69f458c9db6301a3c9413ea43da4fae9b74cebf5b387a951828a058256c26db99926eb8a89851cfda74f85d879c90809586e3284c1503de
7
- data.tar.gz: ed09985141339c9fe27f9f377bf84ed8e4c0e902609f0eddb493d235f9fc0ee78812cb7afd97592a4ff3c83fe3a0c0e281b9feb706f136360d253f2dd57c7093
6
+ metadata.gz: 01e10ee66306428c3185065f036d33b54b76520e448510048a35a39e29ba6180bf256065183f472df5471f3df8b4e671f33f72c0dc2eab591b38be19c7a2eded
7
+ data.tar.gz: 5a1d5c5833d61581879e0204197dfacd511ae8d27042234372d0b41350beed0e52daf959952d7df8d16732738695ee73a0f3dbfdfa3381cb6769ce5f8981534d
data/README.md CHANGED
@@ -197,19 +197,17 @@ This logging includes the resource's base attributes, all autosaved associations
197
197
 
198
198
  It will recurse through all accepts_nested_attributes has_many's and handle any number of child objects.
199
199
 
200
- Add to your model:
200
+ Add to your application controller:
201
201
 
202
- ```ruby
203
- class Post < ActiveRecord::Base
204
- log_changes
205
- end
202
+ ```
203
+ around_action :set_effective_logging_current_user
206
204
  ```
207
205
 
208
- and to your controller:
206
+ Add to your model:
209
207
 
210
208
  ```ruby
211
- class ApplicationController < ActionController::Base
212
- before_action :set_effective_logging_current_user
209
+ class Post < ActiveRecord::Base
210
+ log_changes
213
211
  end
214
212
  ```
215
213
 
@@ -371,4 +369,3 @@ MIT License. Copyright [Code and Effect Inc.](http://www.codeandeffect.com/)
371
369
  4. Push to the branch (`git push origin my-new-feature`)
372
370
  5. Bonus points for test coverage
373
371
  6. Create new Pull Request
374
-
@@ -21,7 +21,8 @@ class EffectiveLogChangesDatatable < Effective::Datatable
21
21
  end
22
22
 
23
23
  end.search do |collection, term, column, sql_column|
24
- collection.where("associated_type #{resource.ilike} ? OR associated_to_s #{resource.ilike} ? OR message #{resource.ilike} ?", "%#{term}%", "%#{term}%", "%#{term}%")
24
+ ilike = effective_resource.ilike
25
+ collection.where("associated_type #{ilike} ? OR associated_to_s #{ilike} ? OR message #{ilike} ?", "%#{term}%", "%#{term}%", "%#{term}%")
25
26
  end
26
27
 
27
28
  col :details, visible: false, sort: false do |log|
@@ -40,7 +40,7 @@
40
40
  - next unless value.present?
41
41
  .row
42
42
  .col-md-12
43
- %p
43
+ .mt-3
44
44
  %strong= "#{key.to_s.titleize}:"
45
45
  = format_log_details_value(log, key)
46
46
 
@@ -50,4 +50,3 @@
50
50
 
51
51
  - unless log.datatable.nil?
52
52
  = render_datatable(log.datatable)
53
-
@@ -5,7 +5,7 @@ module EffectiveLogging
5
5
  return unless message.present?
6
6
 
7
7
  # collect a Hash of arguments used to invoke EffectiveLogger.success
8
- logged_fields = { from: message.from.join(','), to: message.to, subject: message.subject }
8
+ logged_fields = { from: message.from.join(','), to: message.to, subject: message.subject, cc: message.cc, bcc: message.bcc }
9
9
 
10
10
  # Add a log header to your mailer to pass some objects or additional things to EffectiveLogger
11
11
  # mail(to: 'admin@example.com', subject: @post.title, log: { post: @post })
@@ -18,10 +18,11 @@ module EffectiveLogging
18
18
  end
19
19
 
20
20
  body = (message.body.try(:parts) || []).find { |part| part.content_type.to_s.downcase.include?('text/html') }
21
+ to = Array(message.to) - [nil, '']
21
22
 
22
23
  logged_fields[:email] = "#{message.header}<hr>#{(body.presence || message.body)}"
23
24
 
24
- (message.to || []).each do |to|
25
+ to.each do |to|
25
26
  user = (User.where(email: to).first rescue nil)
26
27
 
27
28
  logged_fields[:to] = to
@@ -30,6 +31,11 @@ module EffectiveLogging
30
31
 
31
32
  ::EffectiveLogger.email("#{message.subject} - #{message.to.join(', ')}", logged_fields)
32
33
  end
34
+
35
+ if to.blank? && (message.cc.present? || message.bcc.present?)
36
+ ::EffectiveLogger.email("#{message.subject} - multiple recipients", logged_fields)
37
+ end
38
+
33
39
  end
34
40
 
35
41
  end
@@ -1,11 +1,13 @@
1
1
  require 'effective_logging/active_record_logger'
2
+ require 'effective_logging/email_logger'
3
+ require 'effective_logging/log_page_views'
4
+ require 'effective_logging/set_current_user'
5
+ require 'effective_logging/user_logger'
2
6
 
3
7
  module EffectiveLogging
4
8
  class Engine < ::Rails::Engine
5
9
  engine_name 'effective_logging'
6
10
 
7
- config.autoload_paths += Dir["#{config.root}/lib/"]
8
-
9
11
  # Set up our default configuration options.
10
12
  initializer "effective_logging.defaults", :before => :load_config_initializers do |app|
11
13
  eval File.read("#{config.root}/config/effective_logging.rb")
@@ -14,7 +16,6 @@ module EffectiveLogging
14
16
  # Automatically Log Emails
15
17
  initializer 'effective_logging.emails' do |app|
16
18
  if EffectiveLogging.email_enabled == true
17
- require 'effective_logging/email_logger'
18
19
  ActionMailer::Base.register_interceptor(EffectiveLogging::EmailLogger)
19
20
  end
20
21
  end
@@ -30,7 +31,6 @@ module EffectiveLogging
30
31
  initializer 'effective_logging.log_changes_action_controller' do |app|
31
32
  Rails.application.config.to_prepare do
32
33
  ActiveSupport.on_load :action_controller do
33
- require 'effective_logging/set_current_user'
34
34
  ActionController::Base.include(EffectiveLogging::SetCurrentUser::ActionController)
35
35
  end
36
36
  end
@@ -3,13 +3,17 @@ module EffectiveLogging
3
3
  module ActionController
4
4
 
5
5
  # Add me to your ApplicationController
6
- # before_action :set_effective_logging_current_user
6
+ # around_action :set_effective_logging_current_user
7
7
 
8
8
  def set_effective_logging_current_user
9
9
  EffectiveLogging.current_user = current_user
10
+
11
+ if block_given?
12
+ yield
13
+ EffectiveLogging.current_user = nil
14
+ end
10
15
  end
11
16
 
12
17
  end
13
18
  end
14
19
  end
15
-
@@ -1,3 +1,3 @@
1
1
  module EffectiveLogging
2
- VERSION = '3.0.7'.freeze
2
+ VERSION = '3.0.12'.freeze
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: effective_logging
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.0.7
4
+ version: 3.0.12
5
5
  platform: ruby
6
6
  authors:
7
7
  - Code and Effect
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-05-31 00:00:00.000000000 Z
11
+ date: 2021-01-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -123,7 +123,7 @@ homepage: https://github.com/code-and-effect/effective_logging
123
123
  licenses:
124
124
  - MIT
125
125
  metadata: {}
126
- post_install_message:
126
+ post_install_message:
127
127
  rdoc_options: []
128
128
  require_paths:
129
129
  - lib
@@ -139,7 +139,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
139
139
  version: '0'
140
140
  requirements: []
141
141
  rubygems_version: 3.1.2
142
- signing_key:
142
+ signing_key:
143
143
  specification_version: 4
144
144
  summary: Automatically log all sent emails, user logins, and page views. This also
145
145
  will log custom events from Ruby and JavaScript.