logstruct 0.1.2 → 0.1.3
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 +12 -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/shrine.rb +21 -24
- data/lib/log_struct/integrations/sidekiq/logger.rb +8 -1
- 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 +0 -22
- 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
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.3
|
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
|