logstruct 0.1.2 → 0.1.4
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/CHANGELOG.md +16 -1
- data/README.md +4 -6
- data/lib/log_struct/concerns/configuration.rb +2 -2
- data/lib/log_struct/config_struct/integrations.rb +5 -0
- data/lib/log_struct/enums/log_field.rb +12 -1
- data/lib/log_struct/integrations/action_mailer/error_handling.rb +121 -27
- data/lib/log_struct/integrations/action_mailer/event_logging.rb +30 -14
- data/lib/log_struct/integrations/action_mailer/metadata_collection.rb +18 -24
- data/lib/log_struct/integrations/action_mailer.rb +13 -6
- data/lib/log_struct/integrations/active_job/log_subscriber.rb +2 -2
- data/lib/log_struct/integrations/active_storage.rb +8 -8
- data/lib/log_struct/integrations/ahoy.rb +2 -3
- data/lib/log_struct/integrations/carrierwave.rb +8 -10
- data/lib/log_struct/integrations/good_job/log_subscriber.rb +5 -5
- data/lib/log_struct/integrations/good_job/logger.rb +2 -6
- data/lib/log_struct/integrations/good_job.rb +1 -1
- data/lib/log_struct/integrations/host_authorization.rb +27 -36
- data/lib/log_struct/integrations/lograge.rb +1 -1
- data/lib/log_struct/integrations/rack_error_handler/middleware.rb +54 -16
- data/lib/log_struct/integrations/rack_error_handler.rb +3 -3
- data/lib/log_struct/integrations/shrine.rb +21 -24
- data/lib/log_struct/integrations/sidekiq/logger.rb +8 -1
- data/lib/log_struct/integrations.rb +25 -5
- data/lib/log_struct/log/action_mailer/delivered.rb +14 -49
- data/lib/log_struct/log/action_mailer/delivery.rb +14 -49
- data/lib/log_struct/log/action_mailer/error.rb +72 -0
- data/lib/log_struct/log/action_mailer.rb +15 -2
- data/lib/log_struct/log/active_job/enqueue.rb +9 -73
- data/lib/log_struct/log/active_job/finish.rb +9 -76
- data/lib/log_struct/log/active_job/schedule.rb +9 -73
- data/lib/log_struct/log/active_job/start.rb +9 -76
- data/lib/log_struct/log/active_job.rb +2 -2
- data/lib/log_struct/log/active_model_serializers.rb +5 -45
- data/lib/log_struct/log/active_storage/delete.rb +8 -46
- data/lib/log_struct/log/active_storage/download.rb +9 -55
- data/lib/log_struct/log/active_storage/exist.rb +9 -49
- data/lib/log_struct/log/active_storage/metadata.rb +9 -49
- data/lib/log_struct/log/active_storage/stream.rb +9 -49
- data/lib/log_struct/log/active_storage/upload.rb +9 -64
- data/lib/log_struct/log/active_storage/url.rb +9 -49
- data/lib/log_struct/log/active_storage.rb +2 -2
- data/lib/log_struct/log/ahoy.rb +5 -43
- data/lib/log_struct/log/carrierwave/delete.rb +15 -69
- data/lib/log_struct/log/carrierwave/download.rb +15 -77
- data/lib/log_struct/log/carrierwave/upload.rb +15 -83
- data/lib/log_struct/log/carrierwave.rb +13 -4
- data/lib/log_struct/log/dotenv/load.rb +5 -33
- data/lib/log_struct/log/dotenv/restore.rb +5 -33
- data/lib/log_struct/log/dotenv/save.rb +5 -33
- data/lib/log_struct/log/dotenv/update.rb +5 -33
- data/lib/log_struct/log/error.rb +7 -40
- data/lib/log_struct/log/good_job/enqueue.rb +9 -72
- data/lib/log_struct/log/good_job/error.rb +9 -89
- data/lib/log_struct/log/good_job/finish.rb +9 -78
- data/lib/log_struct/log/good_job/log.rb +11 -75
- data/lib/log_struct/log/good_job/schedule.rb +7 -78
- data/lib/log_struct/log/good_job/start.rb +7 -78
- data/lib/log_struct/log/good_job.rb +2 -2
- data/lib/log_struct/log/plain.rb +5 -32
- data/lib/log_struct/log/puma/shutdown.rb +5 -32
- data/lib/log_struct/log/puma/start.rb +5 -56
- data/lib/log_struct/log/request.rb +7 -90
- data/lib/log_struct/log/security/blocked_host.rb +12 -73
- data/lib/log_struct/log/security/csrf_violation.rb +6 -67
- data/lib/log_struct/log/security/ip_spoof.rb +6 -73
- data/lib/log_struct/log/shrine/delete.rb +6 -41
- data/lib/log_struct/log/shrine/download.rb +6 -44
- data/lib/log_struct/log/shrine/exist.rb +6 -44
- data/lib/log_struct/log/shrine/metadata.rb +8 -46
- data/lib/log_struct/log/shrine/upload.rb +6 -53
- data/lib/log_struct/log/sidekiq.rb +5 -42
- data/lib/log_struct/log/sql.rb +5 -65
- data/lib/log_struct/log.rb +2 -2
- data/lib/log_struct/monkey_patches/active_support/tagged_logging/formatter.rb +12 -1
- data/lib/log_struct/railtie.rb +11 -24
- data/lib/log_struct/semantic_logger/concerns/log_methods.rb +100 -0
- data/lib/log_struct/semantic_logger/logger.rb +46 -15
- data/lib/log_struct/semantic_logger/setup.rb +11 -7
- data/lib/log_struct/shared/{shared/add_request_fields.rb → add_request_fields.rb} +2 -2
- data/lib/log_struct/shared/{shared/merge_additional_data_fields.rb → merge_additional_data_fields.rb} +1 -1
- data/lib/log_struct/shared/{shared/serialize_common.rb → serialize_common.rb} +9 -3
- data/lib/log_struct/{log/shared → shared}/serialize_common_public.rb +2 -2
- data/lib/log_struct/version.rb +1 -1
- data/lib/log_struct.rb +4 -1
- data/logstruct.gemspec +1 -1
- metadata +9 -11
- data/lib/log_struct/integrations/action_mailer/callbacks.rb +0 -100
- data/lib/log_struct/log/shared/add_request_fields.rb +0 -4
- data/lib/log_struct/log/shared/merge_additional_data_fields.rb +0 -4
- data/lib/log_struct/log/shared/serialize_common.rb +0 -4
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
# typed: strict
|
|
2
|
+
# frozen_string_literal: true
|
|
3
|
+
|
|
4
|
+
module LogStruct
|
|
5
|
+
module SemanticLogger
|
|
6
|
+
module Concerns
|
|
7
|
+
module LogMethods
|
|
8
|
+
extend T::Sig
|
|
9
|
+
extend T::Helpers
|
|
10
|
+
requires_ancestor { LogStruct::SemanticLogger::Logger }
|
|
11
|
+
|
|
12
|
+
# Override log methods to handle LogStruct types and broadcast
|
|
13
|
+
sig { params(message: T.untyped, payload: T.untyped, block: T.nilable(T.proc.returns(String))).returns(T::Boolean) }
|
|
14
|
+
def debug(message = nil, payload = nil, &block)
|
|
15
|
+
instrument_log(message, :debug)
|
|
16
|
+
result = if message.is_a?(LogStruct::Log::Interfaces::CommonFields) || message.is_a?(T::Struct) || message.is_a?(Hash)
|
|
17
|
+
super(nil, payload: message, &block)
|
|
18
|
+
else
|
|
19
|
+
super
|
|
20
|
+
end
|
|
21
|
+
broadcasts.each do |logger|
|
|
22
|
+
next unless logger.respond_to?(:debug)
|
|
23
|
+
message.is_a?(String) ? logger.debug(message) : (logger.debug(&block) if block)
|
|
24
|
+
end
|
|
25
|
+
result
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
sig { params(message: T.untyped, payload: T.untyped, block: T.nilable(T.proc.returns(String))).returns(T::Boolean) }
|
|
29
|
+
def info(message = nil, payload = nil, &block)
|
|
30
|
+
instrument_log(message, :info)
|
|
31
|
+
result = if message.is_a?(LogStruct::Log::Interfaces::CommonFields) || message.is_a?(T::Struct) || message.is_a?(Hash)
|
|
32
|
+
super(nil, payload: message, &block)
|
|
33
|
+
else
|
|
34
|
+
super
|
|
35
|
+
end
|
|
36
|
+
broadcasts.each do |logger|
|
|
37
|
+
next unless logger.respond_to?(:info)
|
|
38
|
+
message.is_a?(String) ? logger.info(message) : (logger.info(&block) if block)
|
|
39
|
+
end
|
|
40
|
+
result
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
sig { params(message: T.untyped, payload: T.untyped, block: T.nilable(T.proc.returns(String))).returns(T::Boolean) }
|
|
44
|
+
def warn(message = nil, payload = nil, &block)
|
|
45
|
+
instrument_log(message, :warn)
|
|
46
|
+
result = if message.is_a?(LogStruct::Log::Interfaces::CommonFields) || message.is_a?(T::Struct) || message.is_a?(Hash)
|
|
47
|
+
super(nil, payload: message, &block)
|
|
48
|
+
else
|
|
49
|
+
super
|
|
50
|
+
end
|
|
51
|
+
broadcasts.each do |logger|
|
|
52
|
+
next unless logger.respond_to?(:warn)
|
|
53
|
+
message.is_a?(String) ? logger.warn(message) : (logger.warn(&block) if block)
|
|
54
|
+
end
|
|
55
|
+
result
|
|
56
|
+
end
|
|
57
|
+
|
|
58
|
+
sig { params(message: T.untyped, payload: T.untyped, block: T.nilable(T.proc.returns(String))).returns(T::Boolean) }
|
|
59
|
+
def error(message = nil, payload = nil, &block)
|
|
60
|
+
instrument_log(message, :error)
|
|
61
|
+
result = if message.is_a?(LogStruct::Log::Interfaces::CommonFields) || message.is_a?(T::Struct) || message.is_a?(Hash)
|
|
62
|
+
super(nil, payload: message, &block)
|
|
63
|
+
else
|
|
64
|
+
super
|
|
65
|
+
end
|
|
66
|
+
broadcasts.each do |logger|
|
|
67
|
+
next unless logger.respond_to?(:error)
|
|
68
|
+
message.is_a?(String) ? logger.error(message) : (logger.error(&block) if block)
|
|
69
|
+
end
|
|
70
|
+
result
|
|
71
|
+
end
|
|
72
|
+
|
|
73
|
+
sig { params(message: T.untyped, payload: T.untyped, block: T.nilable(T.proc.returns(String))).returns(T::Boolean) }
|
|
74
|
+
def fatal(message = nil, payload = nil, &block)
|
|
75
|
+
instrument_log(message, :fatal)
|
|
76
|
+
result = if message.is_a?(LogStruct::Log::Interfaces::CommonFields) || message.is_a?(T::Struct) || message.is_a?(Hash)
|
|
77
|
+
super(nil, payload: message, &block)
|
|
78
|
+
else
|
|
79
|
+
super
|
|
80
|
+
end
|
|
81
|
+
broadcasts.each do |logger|
|
|
82
|
+
next unless logger.respond_to?(:fatal)
|
|
83
|
+
message.is_a?(String) ? logger.fatal(message) : (logger.fatal(&block) if block)
|
|
84
|
+
end
|
|
85
|
+
result
|
|
86
|
+
end
|
|
87
|
+
|
|
88
|
+
private
|
|
89
|
+
|
|
90
|
+
# Instrument log events for subscribers
|
|
91
|
+
sig { params(message: T.untyped, level: Symbol).void }
|
|
92
|
+
def instrument_log(message, level)
|
|
93
|
+
return unless message.is_a?(LogStruct::Log::Interfaces::CommonFields) || message.is_a?(T::Struct)
|
|
94
|
+
|
|
95
|
+
::ActiveSupport::Notifications.instrument("log.logstruct", log: message, level: level)
|
|
96
|
+
end
|
|
97
|
+
end
|
|
98
|
+
end
|
|
99
|
+
end
|
|
100
|
+
end
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
# frozen_string_literal: true
|
|
3
3
|
|
|
4
4
|
require "semantic_logger"
|
|
5
|
+
require_relative "concerns/log_methods"
|
|
5
6
|
|
|
6
7
|
module LogStruct
|
|
7
8
|
module SemanticLogger
|
|
@@ -69,25 +70,37 @@ module LogStruct
|
|
|
69
70
|
def initialize(name = "Application", level: nil, filter: nil)
|
|
70
71
|
# SemanticLogger::Logger expects positional arguments, not named arguments
|
|
71
72
|
super(name, level, filter)
|
|
73
|
+
# T.untyped because users can pass any logger: ::Logger, ActiveSupport::Logger,
|
|
74
|
+
# custom loggers (FakeLogger in tests), or third-party loggers
|
|
75
|
+
@broadcasts = T.let([], T::Array[T.untyped])
|
|
76
|
+
# ActiveJob expects logger.formatter to exist and respond to current_tags
|
|
77
|
+
@formatter = T.let(FormatterProxy.new, FormatterProxy)
|
|
72
78
|
end
|
|
73
79
|
|
|
74
|
-
#
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
80
|
+
# ActiveSupport::BroadcastLogger compatibility
|
|
81
|
+
# These methods allow Rails.logger to broadcast to multiple loggers
|
|
82
|
+
sig { returns(T::Array[T.untyped]) }
|
|
83
|
+
attr_reader :broadcasts
|
|
84
|
+
|
|
85
|
+
# ActiveJob compatibility - expects logger.formatter.current_tags
|
|
86
|
+
sig { returns(FormatterProxy) }
|
|
87
|
+
attr_reader :formatter
|
|
88
|
+
|
|
89
|
+
# T.untyped for logger param because we accept any logger-like object:
|
|
90
|
+
# ::Logger, ActiveSupport::Logger, test doubles, etc.
|
|
91
|
+
sig { params(logger: T.untyped).returns(T.untyped) }
|
|
92
|
+
def broadcast_to(logger)
|
|
93
|
+
@broadcasts << logger
|
|
94
|
+
logger
|
|
95
|
+
end
|
|
96
|
+
|
|
97
|
+
sig { params(logger: T.untyped).void }
|
|
98
|
+
def stop_broadcasting_to(logger)
|
|
99
|
+
@broadcasts.delete(logger)
|
|
89
100
|
end
|
|
90
101
|
|
|
102
|
+
include Concerns::LogMethods
|
|
103
|
+
|
|
91
104
|
# Support for tagged logging
|
|
92
105
|
sig { params(tags: T.untyped, block: T.proc.returns(T.untyped)).returns(T.untyped) }
|
|
93
106
|
def tagged(*tags, &block)
|
|
@@ -124,6 +137,24 @@ module LogStruct
|
|
|
124
137
|
def pop_tags(count = 1)
|
|
125
138
|
::SemanticLogger.pop_tags(count)
|
|
126
139
|
end
|
|
140
|
+
|
|
141
|
+
# Support for << operator (used by RailsLogSplitter)
|
|
142
|
+
sig { params(msg: String).returns(T.self_type) }
|
|
143
|
+
def <<(msg)
|
|
144
|
+
info(msg)
|
|
145
|
+
@broadcasts.each { |logger| logger << msg if logger.respond_to?(:<<) }
|
|
146
|
+
self
|
|
147
|
+
end
|
|
148
|
+
end
|
|
149
|
+
|
|
150
|
+
# Proxy object to provide ActiveJob-compatible formatter interface
|
|
151
|
+
class FormatterProxy
|
|
152
|
+
extend T::Sig
|
|
153
|
+
|
|
154
|
+
sig { returns(T::Array[T.any(String, Symbol)]) }
|
|
155
|
+
def current_tags
|
|
156
|
+
Thread.current[:activesupport_tagged_logging_tags] || []
|
|
157
|
+
end
|
|
127
158
|
end
|
|
128
159
|
end
|
|
129
160
|
end
|
|
@@ -152,8 +152,8 @@ module LogStruct
|
|
|
152
152
|
)
|
|
153
153
|
end
|
|
154
154
|
|
|
155
|
-
# Add file appender if
|
|
156
|
-
if app.config.paths["log"].first
|
|
155
|
+
# Add file appender if Rails has a log path configured (normal Rails behavior)
|
|
156
|
+
if app.config.paths["log"].first
|
|
157
157
|
::SemanticLogger.add_appender(
|
|
158
158
|
file_name: app.config.paths["log"].first,
|
|
159
159
|
formatter: LogStruct::SemanticLogger::Formatter.new,
|
|
@@ -164,14 +164,14 @@ module LogStruct
|
|
|
164
164
|
|
|
165
165
|
sig { params(app: T.untyped).returns(T.untyped) }
|
|
166
166
|
def self.determine_output(app)
|
|
167
|
-
# Always honor explicit STDOUT directive
|
|
168
|
-
return $stdout if ENV["RAILS_LOG_TO_STDOUT"].present?
|
|
167
|
+
# Always honor explicit STDOUT directive
|
|
168
|
+
return $stdout if ENV["RAILS_LOG_TO_STDOUT"].present?
|
|
169
169
|
|
|
170
170
|
if Rails.env.test?
|
|
171
|
-
#
|
|
171
|
+
# Use StringIO in test to keep stdout clean
|
|
172
172
|
StringIO.new
|
|
173
173
|
else
|
|
174
|
-
#
|
|
174
|
+
# Use STDOUT for app logs in dev/production
|
|
175
175
|
$stdout
|
|
176
176
|
end
|
|
177
177
|
end
|
|
@@ -222,7 +222,11 @@ module LogStruct
|
|
|
222
222
|
# Also replace various component loggers
|
|
223
223
|
ActiveRecord::Base.logger = logger if defined?(ActiveRecord::Base)
|
|
224
224
|
ActionController::Base.logger = logger if defined?(ActionController::Base)
|
|
225
|
-
|
|
225
|
+
if defined?(ActionMailer::Base)
|
|
226
|
+
ActionMailer::Base.logger = logger
|
|
227
|
+
# Ensure ActionMailer.logger is also set (it might be accessed directly)
|
|
228
|
+
T.unsafe(::ActionMailer).logger = logger if T.unsafe(::ActionMailer).respond_to?(:logger=)
|
|
229
|
+
end
|
|
226
230
|
ActiveJob::Base.logger = logger if defined?(ActiveJob::Base)
|
|
227
231
|
ActionView::Base.logger = logger if defined?(ActionView::Base)
|
|
228
232
|
ActionCable.server.config.logger = logger if defined?(ActionCable)
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
# typed: strict
|
|
2
2
|
# frozen_string_literal: true
|
|
3
3
|
|
|
4
|
-
require_relative "
|
|
5
|
-
require_relative "
|
|
4
|
+
require_relative "../enums/log_field"
|
|
5
|
+
require_relative "interfaces/request_fields"
|
|
6
6
|
|
|
7
7
|
module LogStruct
|
|
8
8
|
module Log
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
# typed: strict
|
|
2
2
|
# frozen_string_literal: true
|
|
3
3
|
|
|
4
|
-
require_relative "
|
|
5
|
-
require_relative "
|
|
6
|
-
require_relative "
|
|
4
|
+
require_relative "../enums/log_field"
|
|
5
|
+
require_relative "interfaces/common_fields"
|
|
6
|
+
require_relative "merge_additional_data_fields"
|
|
7
7
|
|
|
8
8
|
module LogStruct
|
|
9
9
|
module Log
|
|
@@ -25,6 +25,12 @@ module LogStruct
|
|
|
25
25
|
field_hash.each do |log_field, value|
|
|
26
26
|
next if value.nil?
|
|
27
27
|
key = log_field.serialize
|
|
28
|
+
|
|
29
|
+
# Limit backtrace to first 5 lines
|
|
30
|
+
if key == :backtrace && value.is_a?(Array)
|
|
31
|
+
value = value.first(5)
|
|
32
|
+
end
|
|
33
|
+
|
|
28
34
|
out[key] = value.is_a?(::Time) ? value.iso8601 : value
|
|
29
35
|
end
|
|
30
36
|
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
# typed: strict
|
|
2
2
|
# frozen_string_literal: true
|
|
3
3
|
|
|
4
|
-
require_relative "
|
|
5
|
-
require_relative "
|
|
4
|
+
require_relative "../enums/log_field"
|
|
5
|
+
require_relative "interfaces/public_common_fields"
|
|
6
6
|
|
|
7
7
|
module LogStruct
|
|
8
8
|
module Log
|
data/lib/log_struct/version.rb
CHANGED
data/lib/log_struct.rb
CHANGED
|
@@ -22,6 +22,9 @@ require "log_struct/semantic_logger/logger"
|
|
|
22
22
|
require "log_struct/semantic_logger/setup"
|
|
23
23
|
require "log_struct/rails_boot_banner_silencer"
|
|
24
24
|
|
|
25
|
+
# Monkey patches for Rails compatibility
|
|
26
|
+
require "log_struct/monkey_patches/active_support/tagged_logging/formatter"
|
|
27
|
+
|
|
25
28
|
module LogStruct
|
|
26
29
|
extend T::Sig
|
|
27
30
|
|
|
@@ -44,7 +47,7 @@ module LogStruct
|
|
|
44
47
|
end
|
|
45
48
|
|
|
46
49
|
# Set enabled at require time based on current Rails environment.
|
|
47
|
-
# (Users can
|
|
50
|
+
# (Users can override this in their initializer which runs before the Railtie checks enabled)
|
|
48
51
|
set_enabled_from_rails_env!
|
|
49
52
|
|
|
50
53
|
# Silence Rails boot banners for cleaner server output
|
data/logstruct.gemspec
CHANGED
|
@@ -34,7 +34,7 @@ Gem::Specification.new do |spec|
|
|
|
34
34
|
spec.require_paths = ["lib"]
|
|
35
35
|
|
|
36
36
|
spec.add_dependency "lograge", ">= 0.11"
|
|
37
|
-
spec.add_dependency "rails", ">= 7.
|
|
37
|
+
spec.add_dependency "rails", ">= 7.1"
|
|
38
38
|
spec.add_dependency "semantic_logger", "~> 4.15"
|
|
39
39
|
spec.add_dependency "sorbet-runtime", ">= 0.5"
|
|
40
40
|
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: logstruct
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.1.
|
|
4
|
+
version: 0.1.4
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- DocSpring
|
|
@@ -29,14 +29,14 @@ dependencies:
|
|
|
29
29
|
requirements:
|
|
30
30
|
- - ">="
|
|
31
31
|
- !ruby/object:Gem::Version
|
|
32
|
-
version: '7.
|
|
32
|
+
version: '7.1'
|
|
33
33
|
type: :runtime
|
|
34
34
|
prerelease: false
|
|
35
35
|
version_requirements: !ruby/object:Gem::Requirement
|
|
36
36
|
requirements:
|
|
37
37
|
- - ">="
|
|
38
38
|
- !ruby/object:Gem::Version
|
|
39
|
-
version: '7.
|
|
39
|
+
version: '7.1'
|
|
40
40
|
- !ruby/object:Gem::Dependency
|
|
41
41
|
name: semantic_logger
|
|
42
42
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -260,7 +260,6 @@ files:
|
|
|
260
260
|
- lib/log_struct/hash_utils.rb
|
|
261
261
|
- lib/log_struct/integrations.rb
|
|
262
262
|
- lib/log_struct/integrations/action_mailer.rb
|
|
263
|
-
- lib/log_struct/integrations/action_mailer/callbacks.rb
|
|
264
263
|
- lib/log_struct/integrations/action_mailer/error_handling.rb
|
|
265
264
|
- lib/log_struct/integrations/action_mailer/event_logging.rb
|
|
266
265
|
- lib/log_struct/integrations/action_mailer/metadata_collection.rb
|
|
@@ -290,6 +289,7 @@ files:
|
|
|
290
289
|
- lib/log_struct/log/action_mailer.rb
|
|
291
290
|
- lib/log_struct/log/action_mailer/delivered.rb
|
|
292
291
|
- lib/log_struct/log/action_mailer/delivery.rb
|
|
292
|
+
- lib/log_struct/log/action_mailer/error.rb
|
|
293
293
|
- lib/log_struct/log/active_job.rb
|
|
294
294
|
- lib/log_struct/log/active_job/enqueue.rb
|
|
295
295
|
- lib/log_struct/log/active_job/finish.rb
|
|
@@ -335,10 +335,6 @@ files:
|
|
|
335
335
|
- lib/log_struct/log/security/blocked_host.rb
|
|
336
336
|
- lib/log_struct/log/security/csrf_violation.rb
|
|
337
337
|
- lib/log_struct/log/security/ip_spoof.rb
|
|
338
|
-
- lib/log_struct/log/shared/add_request_fields.rb
|
|
339
|
-
- lib/log_struct/log/shared/merge_additional_data_fields.rb
|
|
340
|
-
- lib/log_struct/log/shared/serialize_common.rb
|
|
341
|
-
- lib/log_struct/log/shared/serialize_common_public.rb
|
|
342
338
|
- lib/log_struct/log/shrine.rb
|
|
343
339
|
- lib/log_struct/log/shrine/delete.rb
|
|
344
340
|
- lib/log_struct/log/shrine/download.rb
|
|
@@ -353,16 +349,18 @@ files:
|
|
|
353
349
|
- lib/log_struct/rails_boot_banner_silencer.rb
|
|
354
350
|
- lib/log_struct/railtie.rb
|
|
355
351
|
- lib/log_struct/semantic_logger/color_formatter.rb
|
|
352
|
+
- lib/log_struct/semantic_logger/concerns/log_methods.rb
|
|
356
353
|
- lib/log_struct/semantic_logger/formatter.rb
|
|
357
354
|
- lib/log_struct/semantic_logger/logger.rb
|
|
358
355
|
- lib/log_struct/semantic_logger/setup.rb
|
|
356
|
+
- lib/log_struct/shared/add_request_fields.rb
|
|
359
357
|
- lib/log_struct/shared/interfaces/additional_data_field.rb
|
|
360
358
|
- lib/log_struct/shared/interfaces/common_fields.rb
|
|
361
359
|
- lib/log_struct/shared/interfaces/public_common_fields.rb
|
|
362
360
|
- lib/log_struct/shared/interfaces/request_fields.rb
|
|
363
|
-
- lib/log_struct/shared/
|
|
364
|
-
- lib/log_struct/shared/
|
|
365
|
-
- lib/log_struct/shared/
|
|
361
|
+
- lib/log_struct/shared/merge_additional_data_fields.rb
|
|
362
|
+
- lib/log_struct/shared/serialize_common.rb
|
|
363
|
+
- lib/log_struct/shared/serialize_common_public.rb
|
|
366
364
|
- lib/log_struct/sorbet.rb
|
|
367
365
|
- lib/log_struct/sorbet/serialize_symbol_keys.rb
|
|
368
366
|
- lib/log_struct/string_scrubber.rb
|
|
@@ -1,100 +0,0 @@
|
|
|
1
|
-
# typed: strict
|
|
2
|
-
# frozen_string_literal: true
|
|
3
|
-
|
|
4
|
-
module LogStruct
|
|
5
|
-
module Integrations
|
|
6
|
-
module ActionMailer
|
|
7
|
-
# Backport of the *_deliver callbacks from Rails 7.1
|
|
8
|
-
module Callbacks
|
|
9
|
-
extend T::Sig
|
|
10
|
-
extend ::ActiveSupport::Concern
|
|
11
|
-
|
|
12
|
-
# Track if we've already patched MessageDelivery
|
|
13
|
-
@patched_message_delivery = T.let(false, T::Boolean)
|
|
14
|
-
|
|
15
|
-
# We can't use included block with strict typing
|
|
16
|
-
# This will be handled by ActiveSupport::Concern at runtime
|
|
17
|
-
included do
|
|
18
|
-
include ::ActiveSupport::Callbacks
|
|
19
|
-
if defined?(::ActiveSupport) && ::ActiveSupport.gem_version >= Gem::Version.new("7.1.0")
|
|
20
|
-
define_callbacks :deliver, skip_after_callbacks_if_terminated: true
|
|
21
|
-
else
|
|
22
|
-
define_callbacks :deliver
|
|
23
|
-
end
|
|
24
|
-
end
|
|
25
|
-
|
|
26
|
-
# When this module is prepended (our integration uses prepend), ensure callbacks are defined
|
|
27
|
-
if respond_to?(:prepended)
|
|
28
|
-
prepended do
|
|
29
|
-
include ::ActiveSupport::Callbacks
|
|
30
|
-
if defined?(::ActiveSupport) && ::ActiveSupport.gem_version >= Gem::Version.new("7.1.0")
|
|
31
|
-
define_callbacks :deliver, skip_after_callbacks_if_terminated: true
|
|
32
|
-
else
|
|
33
|
-
define_callbacks :deliver
|
|
34
|
-
end
|
|
35
|
-
end
|
|
36
|
-
end
|
|
37
|
-
|
|
38
|
-
# Define class methods in a separate module
|
|
39
|
-
module ClassMethods
|
|
40
|
-
extend T::Sig
|
|
41
|
-
|
|
42
|
-
# Defines a callback that will get called right before the
|
|
43
|
-
# message is sent to the delivery method.
|
|
44
|
-
sig { params(filters: T.untyped, blk: T.nilable(T.proc.bind(T.untyped).void)).void }
|
|
45
|
-
def before_deliver(*filters, &blk)
|
|
46
|
-
# Use T.unsafe for splat arguments due to Sorbet limitation
|
|
47
|
-
T.unsafe(self).set_callback(:deliver, :before, *filters, &blk)
|
|
48
|
-
end
|
|
49
|
-
|
|
50
|
-
# Defines a callback that will get called right after the
|
|
51
|
-
# message's delivery method is finished.
|
|
52
|
-
sig { params(filters: T.untyped, blk: T.nilable(T.proc.bind(T.untyped).void)).void }
|
|
53
|
-
def after_deliver(*filters, &blk)
|
|
54
|
-
# Use T.unsafe for splat arguments due to Sorbet limitation
|
|
55
|
-
T.unsafe(self).set_callback(:deliver, :after, *filters, &blk)
|
|
56
|
-
end
|
|
57
|
-
|
|
58
|
-
# Defines a callback that will get called around the message's deliver method.
|
|
59
|
-
sig { params(filters: T.untyped, blk: T.nilable(T.proc.bind(T.untyped).params(arg0: T.untyped).void)).void }
|
|
60
|
-
def around_deliver(*filters, &blk)
|
|
61
|
-
# Use T.unsafe for splat arguments due to Sorbet limitation
|
|
62
|
-
T.unsafe(self).set_callback(:deliver, :around, *filters, &blk)
|
|
63
|
-
end
|
|
64
|
-
end
|
|
65
|
-
|
|
66
|
-
# Module to patch ActionMailer::MessageDelivery with callback support
|
|
67
|
-
module MessageDeliveryCallbacks
|
|
68
|
-
extend T::Sig
|
|
69
|
-
|
|
70
|
-
sig { returns(T.untyped) }
|
|
71
|
-
def deliver_now
|
|
72
|
-
processed_mailer.run_callbacks(:deliver) do
|
|
73
|
-
message.deliver
|
|
74
|
-
end
|
|
75
|
-
end
|
|
76
|
-
|
|
77
|
-
sig { returns(T.untyped) }
|
|
78
|
-
def deliver_now!
|
|
79
|
-
processed_mailer.run_callbacks(:deliver) do
|
|
80
|
-
message.deliver!
|
|
81
|
-
end
|
|
82
|
-
end
|
|
83
|
-
end
|
|
84
|
-
|
|
85
|
-
sig { returns(T::Boolean) }
|
|
86
|
-
def self.patch_message_delivery
|
|
87
|
-
# Return early if we've already patched
|
|
88
|
-
return true if @patched_message_delivery
|
|
89
|
-
|
|
90
|
-
# Prepend our module to add callback support to MessageDelivery
|
|
91
|
-
::ActionMailer::MessageDelivery.prepend(MessageDeliveryCallbacks)
|
|
92
|
-
|
|
93
|
-
# Mark as patched so we don't do it again
|
|
94
|
-
@patched_message_delivery = true
|
|
95
|
-
true
|
|
96
|
-
end
|
|
97
|
-
end
|
|
98
|
-
end
|
|
99
|
-
end
|
|
100
|
-
end
|