effective_logging 3.0.4 → 3.0.9

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: d19680da7bc048d5574223fca115ac877e1ed4e45d346dc71b4ce2895f5d23d0
4
- data.tar.gz: d455d79c1d428c2c753bb46eb10eeafb7bdfa0d861be8fbd13e9afe9a604d2f3
3
+ metadata.gz: 87ea6d6a2184d29eec7b23d56bde3f84c17f16b8f6058a9823849c5ee56edc50
4
+ data.tar.gz: 0bb7c7040965bc8bb4587a1668d01902b4c85d26c574269b7b130a41325a570e
5
5
  SHA512:
6
- metadata.gz: ea2a885212f36741a713880b58ae621a04d1ed8980d2ecd150a0936f60996f5047d3aa3d4fe03cc4a6734be1e3483a6141cc5354596d02cabfb1eb4e1292d63a
7
- data.tar.gz: 421254b96a6138f2c6e1353a7f3a3c97a34e34368523d3a7f5db9517d5b66b21d85edadabcf11858177dc82b776dca4c21423c5358d1669e73a73a01c4f66fd9
6
+ metadata.gz: 4c7d6f2d933d8774ebc5142a3e171e03178d5918a392635db966c9aa88b0d6d19127520d644fa2f43733cefc514bb31fb23d68dc542c99133b90922cf5aaa213
7
+ data.tar.gz: 8914c55bdfbe4e3951e25152c095656c2fb649ebd91d3cceca73191b16177f45db31a14339c42363d223a571cefcf9bf1644f7c9683de43d001ea3ff371a6c8b
@@ -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|
@@ -1,7 +1,7 @@
1
1
  module ActsAsLoggable
2
2
  extend ActiveSupport::Concern
3
3
 
4
- module ActiveRecord
4
+ module Base
5
5
  def log_changes(*options)
6
6
  @acts_as_loggable_options = options.try(:first) || {}
7
7
 
@@ -43,6 +43,10 @@ module Effective
43
43
  "Log #{id}"
44
44
  end
45
45
 
46
+ def associated_to_s=(value)
47
+ super(value.to_s[0...255].presence) # Take only first 255 characters
48
+ end
49
+
46
50
  def log(message, status = EffectiveLogging.statuses.first, options = {})
47
51
  EffectiveLogger.log(message, status, (options || {}).merge(parent: self))
48
52
  end
@@ -5,16 +5,17 @@ module EffectiveLogging
5
5
  BLANK = "''"
6
6
  BLACKLIST = [:updated_at, :created_at, :encrypted_password, :status_steps] # Don't log changes or attributes
7
7
 
8
- def initialize(object, to: nil, prefix: nil, only: nil, except: nil)
8
+ # to, prefix, only, except
9
+ def initialize(object, args = {})
9
10
  @object = object
10
11
  @resource = Effective::Resource.new(object)
11
12
 
12
13
  # Validate changes_to value
13
- if to.present? && !@resource.belong_tos.map(&:name).include?(to)
14
- raise ArgumentError.new("unable to find existing belongs_to relationship matching #{to}. Expected a symbol matching a belongs_to.")
14
+ if args[:to].present? && !@resource.belong_tos.map(&:name).include?(args[:to])
15
+ raise ArgumentError.new("unable to find existing belongs_to relationship matching #{args[:to]}. Expected a symbol matching a belongs_to.")
15
16
  end
16
17
 
17
- @options = { to: to, prefix: prefix, only: only, except: Array(except) + BLACKLIST }.compact
18
+ @options = { to: args[:to], prefix: args[:prefix], only: args[:only], except: Array(args[:except]) + BLACKLIST }.compact
18
19
  end
19
20
 
20
21
  # Effective::Log.where(message: 'Deleted').where('details ILIKE ?', '%lab_test_id: 263%')
@@ -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
@@ -22,7 +23,7 @@ module EffectiveLogging
22
23
  # Include acts_as_loggable concern and allow any ActiveRecord object to call it with log_changes()
23
24
  initializer 'effective_logging.active_record' do |app|
24
25
  ActiveSupport.on_load :active_record do
25
- ActiveRecord::Base.extend(ActsAsLoggable::ActiveRecord)
26
+ ActiveRecord::Base.extend(ActsAsLoggable::Base)
26
27
  end
27
28
  end
28
29
 
@@ -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
@@ -1,3 +1,3 @@
1
1
  module EffectiveLogging
2
- VERSION = '3.0.4'.freeze
2
+ VERSION = '3.0.9'.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.4
4
+ version: 3.0.9
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: 2019-12-31 00:00:00.000000000 Z
11
+ date: 2020-08-13 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
@@ -138,8 +138,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
138
138
  - !ruby/object:Gem::Version
139
139
  version: '0'
140
140
  requirements: []
141
- rubygems_version: 3.0.3
142
- signing_key:
141
+ rubygems_version: 3.1.2
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.