effective_logging 1.3.1 → 1.4.0
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 +4 -4
- data/README.md +11 -0
- data/app/models/effective/datatables/logs.rb +26 -25
- data/app/views/admin/logs/_actions.html.haml +14 -0
- data/lib/effective_logging/email_logger.rb +17 -15
- data/lib/effective_logging/engine.rb +1 -1
- data/lib/effective_logging/version.rb +1 -1
- metadata +16 -15
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b74a588e1fd04011eea590704282fc85c6ed9e66
|
4
|
+
data.tar.gz: cb09f89a809c02770b26b1c6c583e31289358e12
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c3933d77a4bd9b28d8f8df76df5fbfbc43002d08dfefc140cb606897b6745f81c98adb3e3b483f74ec5dd85aebaba7216ac24480b574ca2309d3d0d1a20143d2
|
7
|
+
data.tar.gz: e7e6ea41bd18c639999a2d71cf82a31caf7f2cb7c4931525b200cbf545c04df78f38634c2daa01181cd834c8d16d628997ff71af2322f88d65d59577521c0747
|
data/README.md
CHANGED
@@ -98,6 +98,17 @@ This behaviour can be disabled in the config/initializers/effective_logging.rb i
|
|
98
98
|
|
99
99
|
If the TO email address match a User, the :user will be set appropriately.
|
100
100
|
|
101
|
+
You can specify additional fields to be logged via your mailer:
|
102
|
+
|
103
|
+
```ruby
|
104
|
+
def notify_admin_of_new_post(post)
|
105
|
+
mail(
|
106
|
+
to: 'admin@example.com',
|
107
|
+
subject: 'A new post was created',
|
108
|
+
log: { :associated => post, :title => post.title }
|
109
|
+
)
|
110
|
+
end
|
111
|
+
```
|
101
112
|
|
102
113
|
### Automatic Logging of User Login and Logout
|
103
114
|
|
@@ -10,47 +10,48 @@ if defined?(EffectiveDatatables)
|
|
10
10
|
table_column :created_at
|
11
11
|
table_column :id, visible: false
|
12
12
|
|
13
|
-
|
14
|
-
|
13
|
+
unless attributes[:user_id] || attributes[:user] || (attributes[:user] == false)
|
14
|
+
table_column :user
|
15
|
+
end
|
15
16
|
|
16
|
-
|
17
|
+
unless attributes[:status] == false
|
18
|
+
table_column :status, filter: { type: :select, values: EffectiveLogging.statuses }
|
19
|
+
end
|
17
20
|
|
18
|
-
table_column :message
|
21
|
+
table_column :message
|
19
22
|
table_column :logs_count, visible: false
|
20
23
|
|
21
24
|
table_column :details, visible: false, sortable: false do |log|
|
22
|
-
log.details.
|
23
|
-
tableize_hash(log.details, th: true, sub_th: false, width: '100%')
|
25
|
+
tableize_hash(log.details.except(:email), th: true, sub_th: false, width: '100%')
|
24
26
|
end
|
25
27
|
|
26
28
|
table_column :updated_at, visible: false
|
27
29
|
|
28
|
-
|
29
|
-
show_path =
|
30
|
-
if datatables_active_admin_path?
|
31
|
-
admin_effective_log_path(log)
|
32
|
-
elsif datatables_admin_path?
|
33
|
-
effective_logging.admin_log_path(log)
|
34
|
-
else
|
35
|
-
effective_logging.log_path(log)
|
36
|
-
end
|
37
|
-
|
38
|
-
if log.logs_count.to_i > 0
|
39
|
-
link_to "View (#{log.logs_count} more)".html_safe, show_path
|
40
|
-
else
|
41
|
-
link_to 'View', show_path
|
42
|
-
end
|
43
|
-
end
|
30
|
+
actions_column partial: 'admin/logs/actions', partial_local: :log
|
44
31
|
end
|
45
32
|
|
46
33
|
# A nil attributes[:log_id] means give me all the top level log entries
|
47
34
|
# If we set a log_id then it's for sub logs
|
48
35
|
def collection
|
36
|
+
collection = Effective::Log.unscoped.where(parent_id: attributes[:log_id]).includes(:user, :associated)
|
37
|
+
|
49
38
|
if attributes[:user_id].present?
|
50
|
-
|
51
|
-
|
52
|
-
|
39
|
+
collection = collection.where(user_id: attributes[:user_id])
|
40
|
+
end
|
41
|
+
|
42
|
+
if attributes[:user].present?
|
43
|
+
collection = collection.where(user: attributes[:user])
|
53
44
|
end
|
45
|
+
|
46
|
+
if attributes[:associated_id] && attributes[:associated_type]
|
47
|
+
collection = collection.where(associated_id: attributes[:associated_id], associated_type: attributes[:associated_type])
|
48
|
+
end
|
49
|
+
|
50
|
+
if attributes[:associated]
|
51
|
+
collection = collection.where(associated: attributes[:associated])
|
52
|
+
end
|
53
|
+
|
54
|
+
collection
|
54
55
|
end
|
55
56
|
|
56
57
|
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
:ruby
|
2
|
+
show_path =
|
3
|
+
if datatables_active_admin_path?
|
4
|
+
admin_effective_log_path(log)
|
5
|
+
elsif datatables_admin_path?
|
6
|
+
effective_logging.admin_log_path(log)
|
7
|
+
else
|
8
|
+
effective_logging.log_path(log)
|
9
|
+
end
|
10
|
+
|
11
|
+
- if log.logs_count.to_i > 0
|
12
|
+
= link_to "View (#{log.logs_count} more)".html_safe, show_path
|
13
|
+
- else
|
14
|
+
= link_to 'View', show_path
|
@@ -1,26 +1,28 @@
|
|
1
1
|
module EffectiveLogging
|
2
2
|
class EmailLogger
|
3
|
-
def self.
|
3
|
+
def self.delivering_email(message)
|
4
4
|
return unless message.present?
|
5
5
|
|
6
|
-
#
|
7
|
-
|
8
|
-
message_header.gsub!(";\r\n charset", '; charset')
|
6
|
+
# collect a Hash of arguments used to invoke EffectiveLogger.success
|
7
|
+
logged_fields = { from: message.from.join(','), to: message.to, subject: message.subject }
|
9
8
|
|
10
|
-
#
|
11
|
-
|
12
|
-
|
13
|
-
|
9
|
+
# Add a log header to your mailer to pass some objects or additional things to EffectiveLogger
|
10
|
+
# mail(to: 'admin@example.com', subject: @post.title, log: { associated: @post })
|
11
|
+
if message.header['log'].present?
|
12
|
+
# This is a bit sketchy, but gives access to the object in Rails 4.2 anyway
|
13
|
+
logged_fields.merge!(message.header['log'].instance_variable_get(:@value) || {})
|
14
|
+
|
15
|
+
# Get rid of the extra header, as it should not be set in the real mail message.
|
16
|
+
message.header['log'] = nil
|
14
17
|
end
|
15
18
|
|
16
|
-
|
17
|
-
|
19
|
+
logged_fields[:email] = "#{message.header}<hr>#{message.body}"
|
20
|
+
|
21
|
+
(message.to || []).each do |to|
|
22
|
+
logged_fields[:to] = to
|
23
|
+
logged_fields[:user] ||= (User.where(email: to).first rescue nil)
|
18
24
|
|
19
|
-
|
20
|
-
EffectiveLogger.success("email sent: #{message.subject}", :user => user, :recipient => email, :subject => message.subject, :email => message_header + '<hr>' + message_body)
|
21
|
-
else
|
22
|
-
EffectiveLogger.success("email sent to #{email}: #{message.subject}", :recipient => email, :subject => message.subject, :email => message_header + '<hr>' + message_body)
|
23
|
-
end
|
25
|
+
EffectiveLogger.success("email sent: #{message.subject}", logged_fields)
|
24
26
|
end
|
25
27
|
end
|
26
28
|
|
@@ -19,7 +19,7 @@ module EffectiveLogging
|
|
19
19
|
initializer 'effective_logging.emails' do |app|
|
20
20
|
if EffectiveLogging.emails_enabled == true
|
21
21
|
require 'effective_logging/email_logger'
|
22
|
-
ActionMailer::Base.
|
22
|
+
ActionMailer::Base.register_interceptor(EffectiveLogging::EmailLogger)
|
23
23
|
end
|
24
24
|
end
|
25
25
|
|
metadata
CHANGED
@@ -1,83 +1,83 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: effective_logging
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.4.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Code and Effect
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-
|
11
|
+
date: 2016-03-11 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- -
|
17
|
+
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
19
|
version: 3.2.0
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
|
-
- -
|
24
|
+
- - ">="
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: 3.2.0
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: effective_datatables
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
|
-
- -
|
31
|
+
- - ">="
|
32
32
|
- !ruby/object:Gem::Version
|
33
33
|
version: 2.0.0
|
34
34
|
type: :runtime
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
|
-
- -
|
38
|
+
- - ">="
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: 2.0.0
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: coffee-rails
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
|
-
- -
|
45
|
+
- - ">="
|
46
46
|
- !ruby/object:Gem::Version
|
47
47
|
version: '0'
|
48
48
|
type: :runtime
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
|
-
- -
|
52
|
+
- - ">="
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: '0'
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
56
|
name: devise
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
58
58
|
requirements:
|
59
|
-
- -
|
59
|
+
- - ">="
|
60
60
|
- !ruby/object:Gem::Version
|
61
61
|
version: '0'
|
62
62
|
type: :runtime
|
63
63
|
prerelease: false
|
64
64
|
version_requirements: !ruby/object:Gem::Requirement
|
65
65
|
requirements:
|
66
|
-
- -
|
66
|
+
- - ">="
|
67
67
|
- !ruby/object:Gem::Version
|
68
68
|
version: '0'
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
70
|
name: haml-rails
|
71
71
|
requirement: !ruby/object:Gem::Requirement
|
72
72
|
requirements:
|
73
|
-
- -
|
73
|
+
- - ">="
|
74
74
|
- !ruby/object:Gem::Version
|
75
75
|
version: '0'
|
76
76
|
type: :runtime
|
77
77
|
prerelease: false
|
78
78
|
version_requirements: !ruby/object:Gem::Requirement
|
79
79
|
requirements:
|
80
|
-
- -
|
80
|
+
- - ">="
|
81
81
|
- !ruby/object:Gem::Version
|
82
82
|
version: '0'
|
83
83
|
description: Automatically log all sent emails, user logins, and page views. This
|
@@ -102,6 +102,7 @@ files:
|
|
102
102
|
- app/models/effective_logger.rb
|
103
103
|
- app/views/active_admin/effective_logging/logs/index.html.haml
|
104
104
|
- app/views/active_admin/effective_logging/logs/show.html.haml
|
105
|
+
- app/views/admin/logs/_actions.html.haml
|
105
106
|
- app/views/admin/logs/index.html.haml
|
106
107
|
- app/views/admin/logs/show.html.haml
|
107
108
|
- app/views/effective/logs/_log.html.haml
|
@@ -130,17 +131,17 @@ require_paths:
|
|
130
131
|
- lib
|
131
132
|
required_ruby_version: !ruby/object:Gem::Requirement
|
132
133
|
requirements:
|
133
|
-
- -
|
134
|
+
- - ">="
|
134
135
|
- !ruby/object:Gem::Version
|
135
136
|
version: '0'
|
136
137
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
137
138
|
requirements:
|
138
|
-
- -
|
139
|
+
- - ">="
|
139
140
|
- !ruby/object:Gem::Version
|
140
141
|
version: '0'
|
141
142
|
requirements: []
|
142
143
|
rubyforge_project:
|
143
|
-
rubygems_version: 2.4.
|
144
|
+
rubygems_version: 2.4.5.1
|
144
145
|
signing_key:
|
145
146
|
specification_version: 4
|
146
147
|
summary: Automatically log all sent emails, user logins, and page views. This also
|