lograge-action-mailer 0.0.1
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 +7 -0
- data/README.md +34 -0
- data/Rakefile +8 -0
- data/lib/lograge/action_mailer/base_log_subscriber.rb +27 -0
- data/lib/lograge/action_mailer/railtie.rb +20 -0
- data/lib/lograge/action_mailer/version.rb +7 -0
- data/lib/lograge/action_mailer.rb +30 -0
- data/lib/lograge/log_subscribers/action_mailer.rb +29 -0
- data/lib/lograge-action-mailer.rb +7 -0
- metadata +99 -0
checksums.yaml
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
---
|
|
2
|
+
SHA256:
|
|
3
|
+
metadata.gz: 84db2e508897b2ff827e412f14e52e126a9a9440d00df916555c78f0e85cb6c7
|
|
4
|
+
data.tar.gz: 2e098eb9e05416365ffd6687a7dd28567f144b5f3fc6c7c4db60503b946e1208
|
|
5
|
+
SHA512:
|
|
6
|
+
metadata.gz: cbd9db29b08b0f12982790c9b633ffcfa10001052b4a6f1694d5a008f058d03c94dea17ceeb6158fef15abacbdef47d2e183bd10d82d2cbe0377b30843734255
|
|
7
|
+
data.tar.gz: 4400b551e8d71e37988b7d86b5cd937f77c46e9ca90c2ef139360b74f349fa423f5436d9efdc5d5a9a2537c1eef18fb046e7b570f7abf5d7137f7a58cc27c280
|
data/README.md
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
# Lograge::ActionMailer
|
|
2
|
+
|
|
3
|
+
You get a single line with all the important information, like this:
|
|
4
|
+
```log
|
|
5
|
+
"status":"delivered","mailer":"UserMailer","message_id":"61e6b06c20d63_323a76b547849c@application-dev.mail","duration":"855.3ms"
|
|
6
|
+
```
|
|
7
|
+
|
|
8
|
+
## Installation
|
|
9
|
+
|
|
10
|
+
In your Gemfile:
|
|
11
|
+
|
|
12
|
+
```ruby
|
|
13
|
+
gem 'lograge'
|
|
14
|
+
gem 'lograge-action-mailer'
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
Enable it in an initializer or the relevant environment config:
|
|
18
|
+
```ruby
|
|
19
|
+
# config/initializers/lograge.rb
|
|
20
|
+
# OR
|
|
21
|
+
# config/environments/production.rb
|
|
22
|
+
Rails.application.configure do
|
|
23
|
+
config.lograge.action_mailer.enabled = true
|
|
24
|
+
end
|
|
25
|
+
```
|
|
26
|
+
To further clean up your logging, you can also tell Lograge to skip log messages meeting given criteria. You can skip log messages generated from ActionMailer events:
|
|
27
|
+
```ruby
|
|
28
|
+
Rails.application.configure do
|
|
29
|
+
config.lograge.action_mailer.ignore_events = ["process"]
|
|
30
|
+
end
|
|
31
|
+
```
|
|
32
|
+
## License
|
|
33
|
+
|
|
34
|
+
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
|
data/Rakefile
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require "active_support/log_subscriber"
|
|
4
|
+
|
|
5
|
+
module Lograge
|
|
6
|
+
module ActionMailer
|
|
7
|
+
class BaseLogSubscriber < ActiveSupport::LogSubscriber
|
|
8
|
+
protected
|
|
9
|
+
|
|
10
|
+
def processing_data(event, data)
|
|
11
|
+
return if event_ignore?(event.name)
|
|
12
|
+
|
|
13
|
+
logger.send(Lograge.log_level, Lograge.formatter.call(data))
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
private
|
|
17
|
+
|
|
18
|
+
def event_ignore?(name)
|
|
19
|
+
!!Array(Lograge::ActionMailer.ignore_events).index(name.split(".").first)
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
def logger
|
|
23
|
+
Lograge::ActionMailer.logger.presence || Lograge.logger.presence || super
|
|
24
|
+
end
|
|
25
|
+
end
|
|
26
|
+
end
|
|
27
|
+
end
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require "rails/railtie"
|
|
4
|
+
require "active_support"
|
|
5
|
+
require "active_support/ordered_options"
|
|
6
|
+
|
|
7
|
+
module Lograge
|
|
8
|
+
module ActionMailer
|
|
9
|
+
class Railtie < Rails::Railtie
|
|
10
|
+
config.lograge = ActiveSupport::OrderedOptions.new unless config.respond_to?(:lograge)
|
|
11
|
+
config.lograge.action_mailer = ActiveSupport::OrderedOptions.new
|
|
12
|
+
config.lograge.action_mailer.enabled = false
|
|
13
|
+
config.lograge.action_mailer.ignore_events = []
|
|
14
|
+
|
|
15
|
+
config.after_initialize do |app|
|
|
16
|
+
Lograge::ActionMailer.setup(app) if app.config.lograge.action_mailer.enabled
|
|
17
|
+
end
|
|
18
|
+
end
|
|
19
|
+
end
|
|
20
|
+
end
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require "lograge/action_mailer/railtie"
|
|
4
|
+
require "lograge/action_mailer/base_log_subscriber"
|
|
5
|
+
require "lograge/log_subscribers/action_mailer"
|
|
6
|
+
|
|
7
|
+
require "action_mailer/log_subscriber"
|
|
8
|
+
|
|
9
|
+
module Lograge
|
|
10
|
+
module ActionMailer
|
|
11
|
+
class << self
|
|
12
|
+
attr_accessor :logger, :ignore_events
|
|
13
|
+
|
|
14
|
+
def remove_existing_log_subscriptions
|
|
15
|
+
ActiveSupport::LogSubscriber.log_subscribers.each do |subscriber|
|
|
16
|
+
next unless subscriber.is_a?(::ActionMailer::LogSubscriber)
|
|
17
|
+
|
|
18
|
+
Lograge.unsubscribe(:action_mailer, subscriber)
|
|
19
|
+
end
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
def setup(app)
|
|
23
|
+
Lograge::ActionMailer.remove_existing_log_subscriptions
|
|
24
|
+
Lograge::LogSubscribers::ActionMailer.attach_to :action_mailer
|
|
25
|
+
Lograge::ActionMailer.logger = app.config.lograge.action_mailer.logger
|
|
26
|
+
Lograge::ActionMailer.ignore_events = app.config.lograge.action_mailer.ignore_events
|
|
27
|
+
end
|
|
28
|
+
end
|
|
29
|
+
end
|
|
30
|
+
end
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Lograge
|
|
4
|
+
module LogSubscribers
|
|
5
|
+
class ActionMailer < Lograge::ActionMailer::BaseLogSubscriber
|
|
6
|
+
def deliver(event)
|
|
7
|
+
data = {
|
|
8
|
+
status: event.payload[:perform_deliveries] ? :delivered : :skipped,
|
|
9
|
+
mailer: event.payload[:mailer],
|
|
10
|
+
message_id: event.payload[:message_id],
|
|
11
|
+
duration: "#{event.duration.round(1)}ms"
|
|
12
|
+
}.compact
|
|
13
|
+
|
|
14
|
+
processing_data(event, data)
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
def process(event)
|
|
18
|
+
data = {
|
|
19
|
+
status: event.payload[:perform_deliveries] ? :delivered : :skipped,
|
|
20
|
+
mailer: event.payload[:mailer],
|
|
21
|
+
action: event.payload[:action],
|
|
22
|
+
duration: "#{event.duration.round(1)}ms"
|
|
23
|
+
}.compact
|
|
24
|
+
|
|
25
|
+
processing_data(event, data)
|
|
26
|
+
end
|
|
27
|
+
end
|
|
28
|
+
end
|
|
29
|
+
end
|
metadata
ADDED
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
|
2
|
+
name: lograge-action-mailer
|
|
3
|
+
version: !ruby/object:Gem::Version
|
|
4
|
+
version: 0.0.1
|
|
5
|
+
platform: ruby
|
|
6
|
+
authors:
|
|
7
|
+
- Pervushin Alec
|
|
8
|
+
autorequire:
|
|
9
|
+
bindir: bin
|
|
10
|
+
cert_chain: []
|
|
11
|
+
date: 2022-03-17 00:00:00.000000000 Z
|
|
12
|
+
dependencies:
|
|
13
|
+
- !ruby/object:Gem::Dependency
|
|
14
|
+
name: actionmailer
|
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
|
16
|
+
requirements:
|
|
17
|
+
- - ">="
|
|
18
|
+
- !ruby/object:Gem::Version
|
|
19
|
+
version: '5'
|
|
20
|
+
- - "<"
|
|
21
|
+
- !ruby/object:Gem::Version
|
|
22
|
+
version: '7.1'
|
|
23
|
+
type: :runtime
|
|
24
|
+
prerelease: false
|
|
25
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
26
|
+
requirements:
|
|
27
|
+
- - ">="
|
|
28
|
+
- !ruby/object:Gem::Version
|
|
29
|
+
version: '5'
|
|
30
|
+
- - "<"
|
|
31
|
+
- !ruby/object:Gem::Version
|
|
32
|
+
version: '7.1'
|
|
33
|
+
- !ruby/object:Gem::Dependency
|
|
34
|
+
name: lograge
|
|
35
|
+
requirement: !ruby/object:Gem::Requirement
|
|
36
|
+
requirements:
|
|
37
|
+
- - ">"
|
|
38
|
+
- !ruby/object:Gem::Version
|
|
39
|
+
version: '0.11'
|
|
40
|
+
type: :runtime
|
|
41
|
+
prerelease: false
|
|
42
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
43
|
+
requirements:
|
|
44
|
+
- - ">"
|
|
45
|
+
- !ruby/object:Gem::Version
|
|
46
|
+
version: '0.11'
|
|
47
|
+
- !ruby/object:Gem::Dependency
|
|
48
|
+
name: rake
|
|
49
|
+
requirement: !ruby/object:Gem::Requirement
|
|
50
|
+
requirements:
|
|
51
|
+
- - ">="
|
|
52
|
+
- !ruby/object:Gem::Version
|
|
53
|
+
version: 12.3.3
|
|
54
|
+
type: :development
|
|
55
|
+
prerelease: false
|
|
56
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
57
|
+
requirements:
|
|
58
|
+
- - ">="
|
|
59
|
+
- !ruby/object:Gem::Version
|
|
60
|
+
version: 12.3.3
|
|
61
|
+
description: Lograge for ActionMailer.
|
|
62
|
+
email:
|
|
63
|
+
- pervushin.oa@gmail.com
|
|
64
|
+
executables: []
|
|
65
|
+
extensions: []
|
|
66
|
+
extra_rdoc_files: []
|
|
67
|
+
files:
|
|
68
|
+
- README.md
|
|
69
|
+
- Rakefile
|
|
70
|
+
- lib/lograge-action-mailer.rb
|
|
71
|
+
- lib/lograge/action_mailer.rb
|
|
72
|
+
- lib/lograge/action_mailer/base_log_subscriber.rb
|
|
73
|
+
- lib/lograge/action_mailer/railtie.rb
|
|
74
|
+
- lib/lograge/action_mailer/version.rb
|
|
75
|
+
- lib/lograge/log_subscribers/action_mailer.rb
|
|
76
|
+
homepage: https://github.com/one0fnine/lograge-action-mailer
|
|
77
|
+
licenses:
|
|
78
|
+
- MIT
|
|
79
|
+
metadata: {}
|
|
80
|
+
post_install_message:
|
|
81
|
+
rdoc_options: []
|
|
82
|
+
require_paths:
|
|
83
|
+
- lib
|
|
84
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
|
85
|
+
requirements:
|
|
86
|
+
- - ">="
|
|
87
|
+
- !ruby/object:Gem::Version
|
|
88
|
+
version: 2.5.0
|
|
89
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
90
|
+
requirements:
|
|
91
|
+
- - ">="
|
|
92
|
+
- !ruby/object:Gem::Version
|
|
93
|
+
version: '0'
|
|
94
|
+
requirements: []
|
|
95
|
+
rubygems_version: 3.3.7
|
|
96
|
+
signing_key:
|
|
97
|
+
specification_version: 4
|
|
98
|
+
summary: Lograge for ActionMailer.
|
|
99
|
+
test_files: []
|