logstruct 0.2.2 → 0.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.
Files changed (88) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +34 -0
  3. data/lib/log_struct/bounded_input.rb +101 -0
  4. data/lib/log_struct/concerns/configuration.rb +9 -9
  5. data/lib/log_struct/concerns/error_handling.rb +10 -0
  6. data/lib/log_struct/config_struct/filters.rb +24 -13
  7. data/lib/log_struct/config_struct/limits.rb +1 -1
  8. data/lib/log_struct/enums/level.rb +1 -1
  9. data/lib/log_struct/enums/log_field.rb +0 -3
  10. data/lib/log_struct/formatter.rb +38 -23
  11. data/lib/log_struct/hash_utils.rb +11 -4
  12. data/lib/log_struct/integrations/action_mailer/event_logging.rb +1 -0
  13. data/lib/log_struct/integrations/action_mailer/metadata_collection.rb +1 -0
  14. data/lib/log_struct/integrations/active_record.rb +1 -1
  15. data/lib/log_struct/integrations/ahoy.rb +4 -3
  16. data/lib/log_struct/integrations/carrierwave.rb +4 -6
  17. data/lib/log_struct/integrations/dotenv.rb +2 -1
  18. data/lib/log_struct/integrations/good_job.rb +2 -1
  19. data/lib/log_struct/integrations/host_authorization.rb +3 -6
  20. data/lib/log_struct/integrations/lograge.rb +23 -32
  21. data/lib/log_struct/integrations/puma.rb +1 -1
  22. data/lib/log_struct/integrations/rack_error_handler/error_lines.rb +1 -4
  23. data/lib/log_struct/integrations/shrine.rb +1 -1
  24. data/lib/log_struct/log/action_mailer/delivered.rb +19 -7
  25. data/lib/log_struct/log/action_mailer/delivery.rb +19 -7
  26. data/lib/log_struct/log/action_mailer/error.rb +19 -7
  27. data/lib/log_struct/log/action_mailer.rb +1 -0
  28. data/lib/log_struct/log/active_job/discard.rb +7 -5
  29. data/lib/log_struct/log/active_job/enqueue.rb +7 -5
  30. data/lib/log_struct/log/active_job/error.rb +7 -5
  31. data/lib/log_struct/log/active_job/finish.rb +7 -5
  32. data/lib/log_struct/log/active_job/retry.rb +7 -5
  33. data/lib/log_struct/log/active_job/retry_stopped.rb +7 -5
  34. data/lib/log_struct/log/active_job/schedule.rb +7 -5
  35. data/lib/log_struct/log/active_job/start.rb +7 -5
  36. data/lib/log_struct/log/active_job.rb +1 -0
  37. data/lib/log_struct/log/active_model_serializers.rb +7 -5
  38. data/lib/log_struct/log/active_storage/delete.rb +7 -5
  39. data/lib/log_struct/log/active_storage/download.rb +7 -5
  40. data/lib/log_struct/log/active_storage/exist.rb +7 -5
  41. data/lib/log_struct/log/active_storage/metadata.rb +7 -5
  42. data/lib/log_struct/log/active_storage/upload.rb +7 -5
  43. data/lib/log_struct/log/active_storage/url.rb +7 -5
  44. data/lib/log_struct/log/active_storage.rb +1 -0
  45. data/lib/log_struct/log/ahoy.rb +7 -5
  46. data/lib/log_struct/log/carrierwave/delete.rb +7 -9
  47. data/lib/log_struct/log/carrierwave/download.rb +7 -11
  48. data/lib/log_struct/log/carrierwave/upload.rb +7 -11
  49. data/lib/log_struct/log/carrierwave.rb +3 -8
  50. data/lib/log_struct/log/dotenv/load.rb +7 -5
  51. data/lib/log_struct/log/dotenv/restore.rb +7 -5
  52. data/lib/log_struct/log/dotenv/save.rb +7 -5
  53. data/lib/log_struct/log/dotenv/update.rb +7 -5
  54. data/lib/log_struct/log/error.rb +24 -14
  55. data/lib/log_struct/log/good_job/error.rb +7 -5
  56. data/lib/log_struct/log/good_job/log.rb +7 -5
  57. data/lib/log_struct/log/good_job.rb +1 -0
  58. data/lib/log_struct/log/plain.rb +19 -7
  59. data/lib/log_struct/log/puma/error.rb +19 -7
  60. data/lib/log_struct/log/puma/shutdown.rb +19 -7
  61. data/lib/log_struct/log/puma/start.rb +19 -7
  62. data/lib/log_struct/log/request.rb +24 -14
  63. data/lib/log_struct/log/security/blocked_host.rb +24 -14
  64. data/lib/log_struct/log/security/csrf_violation.rb +24 -14
  65. data/lib/log_struct/log/security/ip_spoof.rb +24 -14
  66. data/lib/log_struct/log/security.rb +1 -0
  67. data/lib/log_struct/log/shrine/delete.rb +7 -5
  68. data/lib/log_struct/log/shrine/download.rb +7 -5
  69. data/lib/log_struct/log/shrine/exist.rb +7 -5
  70. data/lib/log_struct/log/shrine/metadata.rb +7 -5
  71. data/lib/log_struct/log/shrine/upload.rb +7 -5
  72. data/lib/log_struct/log/sidekiq/error.rb +19 -7
  73. data/lib/log_struct/log/sidekiq/log.rb +19 -7
  74. data/lib/log_struct/log/sql.rb +19 -7
  75. data/lib/log_struct/monkey_patches/active_support/tagged_logging/formatter.rb +1 -0
  76. data/lib/log_struct/multi_error_reporter.rb +1 -1
  77. data/lib/log_struct/param_filters.rb +7 -26
  78. data/lib/log_struct/params_errors.rb +7 -10
  79. data/lib/log_struct/rails_boot_banner_silencer.rb +1 -0
  80. data/lib/log_struct/semantic_logger/concerns/log_methods.rb +1 -0
  81. data/lib/log_struct/semantic_logger/formatter.rb +1 -1
  82. data/lib/log_struct/semantic_logger/logger.rb +1 -1
  83. data/lib/log_struct/semantic_logger/setup.rb +1 -4
  84. data/lib/log_struct/shared/merge_additional_data_fields.rb +21 -5
  85. data/lib/log_struct/string_scrubber.rb +1 -1
  86. data/lib/log_struct/version.rb +1 -1
  87. data/logstruct.gemspec +1 -1
  88. metadata +4 -3
@@ -157,7 +157,8 @@ module LogStruct
157
157
  return true unless defined?(::GoodJob::Notifier::CONNECTION_ERRORS)
158
158
 
159
159
  ::GoodJob::Notifier::CONNECTION_ERRORS.any? do |error_name|
160
- error_class = error_name.safe_constantize
160
+ # CONNECTION_ERRORS holds class names, because an app might not have loaded the database adapter they belong to
161
+ error_class = error_name.safe_constantize # rubocop:disable Sorbet/ConstantsFromStrings
161
162
  error_class.is_a?(Class) && exception.is_a?(error_class)
162
163
  end
163
164
  end
@@ -12,14 +12,11 @@ module LogStruct
12
12
  extend T::Sig
13
13
  extend IntegrationInterface
14
14
 
15
- RESPONSE_HTML = T.let(
16
- "<html><head><title>Blocked Host</title></head><body>" \
15
+ RESPONSE_HTML = "<html><head><title>Blocked Host</title></head><body>" \
17
16
  "<h1>Blocked Host</h1>" \
18
17
  "<p>This host is not permitted to access this application.</p>" \
19
18
  "<p>If you are the administrator, check your configuration.</p>" \
20
- "</body></html>",
21
- String
22
- )
19
+ "</body></html>"
23
20
  RESPONSE_HEADERS = T.let(
24
21
  {
25
22
  "Content-Type" => "text/html",
@@ -27,7 +24,7 @@ module LogStruct
27
24
  }.freeze,
28
25
  T::Hash[String, String]
29
26
  )
30
- FORBIDDEN_STATUS = T.let(403, Integer)
27
+ FORBIDDEN_STATUS = 403
31
28
 
32
29
  # Set up host authorization logging
33
30
  sig { override.params(config: LogStruct::Configuration).returns(T.nilable(T::Boolean)) }
@@ -6,6 +6,7 @@ begin
6
6
  rescue LoadError
7
7
  # Lograge gem is not available, integration will be skipped
8
8
  end
9
+ require_relative "../bounded_input"
9
10
 
10
11
  module LogStruct
11
12
  module Integrations
@@ -13,28 +14,25 @@ module LogStruct
13
14
  module Lograge
14
15
  extend IntegrationInterface
15
16
 
16
- LOGRAGE_KNOWN_KEYS = T.let(
17
- [
18
- :method,
19
- :path,
20
- :format,
21
- :controller,
22
- :action,
23
- :status,
24
- :duration,
25
- :view,
26
- :db,
27
- :params,
28
- :request_id,
29
- :source_ip,
30
- :user_agent,
31
- :referer,
32
- :host,
33
- :content_type,
34
- :accept
35
- ].freeze,
36
- T::Array[Symbol]
37
- )
17
+ LOGRAGE_KNOWN_KEYS = [
18
+ :method,
19
+ :path,
20
+ :format,
21
+ :controller,
22
+ :action,
23
+ :status,
24
+ :duration,
25
+ :view,
26
+ :db,
27
+ :params,
28
+ :request_id,
29
+ :source_ip,
30
+ :user_agent,
31
+ :referer,
32
+ :host,
33
+ :content_type,
34
+ :accept
35
+ ].freeze
38
36
 
39
37
  # With config.exceptions_app = routes, Rails renders an error page by sending the request through the app again
40
38
  # as GET /<status>, and keeps the request's own method and path in these headers
@@ -196,12 +194,12 @@ module LogStruct
196
194
  result = custom_options_proc.call(event, options)
197
195
  return if !result.is_a?(Hash) || result.equal?(options)
198
196
 
199
- options.merge!(result.to_h { |key, value| [key.to_s.to_sym, value] })
197
+ options.merge!(BoundedInput.symbolize_keys(result))
200
198
  end
201
199
 
202
200
  sig { params(data: T::Hash[T.any(Symbol, String), T.untyped]).returns(Log::Request) }
203
201
  def build_request_log(data)
204
- normalized_data = normalize_lograge_data(data)
202
+ normalized_data = BoundedInput.symbolize_keys(data)
205
203
 
206
204
  # Coerce common fields to expected types
207
205
  status = ((s = normalized_data[:status]) && s.respond_to?(:to_i)) ? s.to_i : s
@@ -210,7 +208,7 @@ module LogStruct
210
208
  db = ((b = normalized_data[:db]) && b.respond_to?(:to_f)) ? b.to_f : b
211
209
 
212
210
  params = normalized_data[:params]
213
- params = params.deep_symbolize_keys if params&.respond_to?(:deep_symbolize_keys)
211
+ params = BoundedInput.symbolize_keys(params) if params.is_a?(Hash) || params.is_a?(::ActionController::Parameters)
214
212
 
215
213
  additional_data = extract_additional_data(normalized_data)
216
214
 
@@ -237,13 +235,6 @@ module LogStruct
237
235
  )
238
236
  end
239
237
 
240
- sig { params(data: T::Hash[T.any(Symbol, String), T.untyped]).returns(T::Hash[Symbol, T.untyped]) }
241
- def normalize_lograge_data(data)
242
- data.each_with_object({}) do |(key, value), normalized|
243
- normalized[key.to_s.to_sym] = value
244
- end
245
- end
246
-
247
238
  sig { params(data: T::Hash[Symbol, T.untyped]).returns(T.nilable(T::Hash[Symbol, T.untyped])) }
248
239
  def extract_additional_data(data)
249
240
  extras = T.let({}, T::Hash[Symbol, T.untyped])
@@ -196,7 +196,7 @@ module LogStruct
196
196
  return true
197
197
  end
198
198
 
199
- if (m = l.match(/^(?:\*\s*)?Puma version: (\S+)(?:.*"([^\"]+)")?/))
199
+ if (m = l.match(/^(?:\*\s*)?Puma version: (\S+)(?:.*"([^"]+)")?/))
200
200
  T.cast(STATE[:start_info], T::Hash[Symbol, T.untyped])[:puma_version] = m[1]
201
201
  if m[2]
202
202
  T.cast(STATE[:start_info], T::Hash[Symbol, T.untyped])[:puma_codename] = m[2]
@@ -12,10 +12,7 @@ module LogStruct
12
12
  module ErrorLines
13
13
  extend T::Sig
14
14
 
15
- CSRF_ERROR_NAMES = T.let(
16
- ["ActionController::InvalidAuthenticityToken", "ActionController::InvalidCrossOriginRequest"].freeze,
17
- T::Array[String]
18
- )
15
+ CSRF_ERROR_NAMES = ["ActionController::InvalidAuthenticityToken", "ActionController::InvalidCrossOriginRequest"].freeze
19
16
 
20
17
  sig { returns(T::Boolean) }
21
18
  def self.enabled?
@@ -14,7 +14,7 @@ module LogStruct
14
14
  extend T::Sig
15
15
  extend IntegrationInterface
16
16
 
17
- SHRINE_EVENTS = T.let(%i[upload exists download delete metadata open].freeze, T::Array[Symbol])
17
+ SHRINE_EVENTS = %i[upload exists download delete metadata open].freeze
18
18
 
19
19
  # The file name in a Content-Disposition (attachment; filename="..."; filename*=UTF-8''...). A quoted name
20
20
  # can hold a semicolon, and whatever follows a quote (malformed or not) goes too.
@@ -23,11 +23,15 @@ module LogStruct
23
23
  class Delivered < T::Struct
24
24
  extend T::Sig
25
25
 
26
+ # A prop marked `override` needs the method it implements to exist already
27
+ include LogStruct::Log::Interfaces::CommonFields
28
+ include LogStruct::Log::Interfaces::AdditionalDataField
29
+
26
30
  # Shared/common fields
27
- const :source, Source::Mailer, default: Source::Mailer
28
- const :event, Event, default: Event::Delivered
29
- const :timestamp, Time, factory: -> { Time.now }
30
- const :level, Level, default: Level::Info
31
+ const :source, Source::Mailer, default: Source::Mailer, override: true
32
+ const :event, Event, default: Event::Delivered, override: true
33
+ const :timestamp, Time, factory: -> { Time.now }, override: true
34
+ const :level, Level, default: Level::Info, override: true
31
35
 
32
36
  const :to, T.nilable(T::Array[String]), default: nil
33
37
  const :from, T.nilable(String), default: nil
@@ -38,12 +42,20 @@ module LogStruct
38
42
  const :attachment_count, T.nilable(Integer), default: nil
39
43
 
40
44
  # Additional data
41
- include LogStruct::Log::Interfaces::AdditionalDataField
42
- const :additional_data, T.nilable(T::Hash[T.any(String, Symbol), T.untyped]), default: nil
45
+ const :additional_data, T.nilable(T::Hash[T.any(String, Symbol), T.untyped]), default: nil, override: true
43
46
  include LogStruct::Log::Shared::MergeAdditionalDataFields
44
47
 
48
+ FIELD_KEYS = T.let(
49
+ [LogField::To, LogField::From, LogField::Subject, LogField::MessageId, LogField::MailerClass, LogField::MailerAction, LogField::AttachmentCount].to_set(&:serialize).freeze,
50
+ T::Set[Symbol]
51
+ )
52
+
53
+ sig { override.returns(T::Set[Symbol]) }
54
+ def field_keys
55
+ FIELD_KEYS
56
+ end
57
+
45
58
  # Serialize shared fields
46
- include LogStruct::Log::Interfaces::CommonFields
47
59
  include LogStruct::Log::Shared::SerializeCommon
48
60
 
49
61
  sig { returns(T::Hash[LogStruct::LogField, T.untyped]) }
@@ -23,11 +23,15 @@ module LogStruct
23
23
  class Delivery < T::Struct
24
24
  extend T::Sig
25
25
 
26
+ # A prop marked `override` needs the method it implements to exist already
27
+ include LogStruct::Log::Interfaces::CommonFields
28
+ include LogStruct::Log::Interfaces::AdditionalDataField
29
+
26
30
  # Shared/common fields
27
- const :source, Source::Mailer, default: Source::Mailer
28
- const :event, Event, default: Event::Delivery
29
- const :timestamp, Time, factory: -> { Time.now }
30
- const :level, Level, default: Level::Info
31
+ const :source, Source::Mailer, default: Source::Mailer, override: true
32
+ const :event, Event, default: Event::Delivery, override: true
33
+ const :timestamp, Time, factory: -> { Time.now }, override: true
34
+ const :level, Level, default: Level::Info, override: true
31
35
 
32
36
  const :to, T.nilable(T::Array[String]), default: nil
33
37
  const :from, T.nilable(String), default: nil
@@ -38,12 +42,20 @@ module LogStruct
38
42
  const :attachment_count, T.nilable(Integer), default: nil
39
43
 
40
44
  # Additional data
41
- include LogStruct::Log::Interfaces::AdditionalDataField
42
- const :additional_data, T.nilable(T::Hash[T.any(String, Symbol), T.untyped]), default: nil
45
+ const :additional_data, T.nilable(T::Hash[T.any(String, Symbol), T.untyped]), default: nil, override: true
43
46
  include LogStruct::Log::Shared::MergeAdditionalDataFields
44
47
 
48
+ FIELD_KEYS = T.let(
49
+ [LogField::To, LogField::From, LogField::Subject, LogField::MessageId, LogField::MailerClass, LogField::MailerAction, LogField::AttachmentCount].to_set(&:serialize).freeze,
50
+ T::Set[Symbol]
51
+ )
52
+
53
+ sig { override.returns(T::Set[Symbol]) }
54
+ def field_keys
55
+ FIELD_KEYS
56
+ end
57
+
45
58
  # Serialize shared fields
46
- include LogStruct::Log::Interfaces::CommonFields
47
59
  include LogStruct::Log::Shared::SerializeCommon
48
60
 
49
61
  sig { returns(T::Hash[LogStruct::LogField, T.untyped]) }
@@ -23,11 +23,15 @@ module LogStruct
23
23
  class Error < T::Struct
24
24
  extend T::Sig
25
25
 
26
+ # A prop marked `override` needs the method it implements to exist already
27
+ include LogStruct::Log::Interfaces::CommonFields
28
+ include LogStruct::Log::Interfaces::AdditionalDataField
29
+
26
30
  # Shared/common fields
27
- const :source, Source::Mailer, default: Source::Mailer
28
- const :event, Event, default: Event::Error
29
- const :timestamp, Time, factory: -> { Time.now }
30
- const :level, Level, default: Level::Info
31
+ const :source, Source::Mailer, default: Source::Mailer, override: true
32
+ const :event, Event, default: Event::Error, override: true
33
+ const :timestamp, Time, factory: -> { Time.now }, override: true
34
+ const :level, Level, default: Level::Info, override: true
31
35
 
32
36
  const :to, T.nilable(T::Array[String]), default: nil
33
37
  const :from, T.nilable(String), default: nil
@@ -43,12 +47,20 @@ module LogStruct
43
47
  const :backtrace, T.nilable(T::Array[String]), default: nil
44
48
 
45
49
  # Additional data
46
- include LogStruct::Log::Interfaces::AdditionalDataField
47
- const :additional_data, T.nilable(T::Hash[T.any(String, Symbol), T.untyped]), default: nil
50
+ const :additional_data, T.nilable(T::Hash[T.any(String, Symbol), T.untyped]), default: nil, override: true
48
51
  include LogStruct::Log::Shared::MergeAdditionalDataFields
49
52
 
53
+ FIELD_KEYS = T.let(
54
+ [LogField::To, LogField::From, LogField::Subject, LogField::MessageId, LogField::MailerClass, LogField::MailerAction, LogField::AttachmentCount, LogField::ErrorClass, LogField::Message, LogField::Backtrace].to_set(&:serialize).freeze,
55
+ T::Set[Symbol]
56
+ )
57
+
58
+ sig { override.returns(T::Set[Symbol]) }
59
+ def field_keys
60
+ FIELD_KEYS
61
+ end
62
+
50
63
  # Serialize shared fields
51
- include LogStruct::Log::Interfaces::CommonFields
52
64
  include LogStruct::Log::Shared::SerializeCommon
53
65
 
54
66
  sig { returns(T::Hash[LogStruct::LogField, T.untyped]) }
@@ -15,6 +15,7 @@ module LogStruct
15
15
  class ActionMailer
16
16
  class BaseFields < T::Struct
17
17
  extend T::Sig
18
+
18
19
  const :to, T.nilable(T::Array[String]), default: nil
19
20
  const :from, T.nilable(String), default: nil
20
21
  const :subject, T.nilable(String), default: nil
@@ -23,11 +23,14 @@ module LogStruct
23
23
  class Discard < T::Struct
24
24
  extend T::Sig
25
25
 
26
+ # A prop marked `override` needs the method it implements to exist already
27
+ include LogStruct::Log::Interfaces::CommonFields
28
+
26
29
  # Shared/common fields
27
- const :source, Source::Job, default: Source::Job
28
- const :event, Event, default: Event::Discard
29
- const :timestamp, Time, factory: -> { Time.now }
30
- const :level, Level, default: Level::Info
30
+ const :source, Source::Job, default: Source::Job, override: true
31
+ const :event, Event, default: Event::Discard, override: true
32
+ const :timestamp, Time, factory: -> { Time.now }, override: true
33
+ const :level, Level, default: Level::Info, override: true
31
34
 
32
35
  const :job_id, String
33
36
  const :job_class, String
@@ -41,7 +44,6 @@ module LogStruct
41
44
  const :message, String
42
45
 
43
46
  # Serialize shared fields
44
- include LogStruct::Log::Interfaces::CommonFields
45
47
  include LogStruct::Log::Shared::SerializeCommon
46
48
 
47
49
  sig { returns(T::Hash[LogStruct::LogField, T.untyped]) }
@@ -23,11 +23,14 @@ module LogStruct
23
23
  class Enqueue < T::Struct
24
24
  extend T::Sig
25
25
 
26
+ # A prop marked `override` needs the method it implements to exist already
27
+ include LogStruct::Log::Interfaces::CommonFields
28
+
26
29
  # Shared/common fields
27
- const :source, Source::Job, default: Source::Job
28
- const :event, Event, default: Event::Enqueue
29
- const :timestamp, Time, factory: -> { Time.now }
30
- const :level, Level, default: Level::Info
30
+ const :source, Source::Job, default: Source::Job, override: true
31
+ const :event, Event, default: Event::Enqueue, override: true
32
+ const :timestamp, Time, factory: -> { Time.now }, override: true
33
+ const :level, Level, default: Level::Info, override: true
31
34
 
32
35
  const :job_id, String
33
36
  const :job_class, String
@@ -37,7 +40,6 @@ module LogStruct
37
40
  const :provider_job_id, T.nilable(String), default: nil
38
41
 
39
42
  # Serialize shared fields
40
- include LogStruct::Log::Interfaces::CommonFields
41
43
  include LogStruct::Log::Shared::SerializeCommon
42
44
 
43
45
  sig { returns(T::Hash[LogStruct::LogField, T.untyped]) }
@@ -23,11 +23,14 @@ module LogStruct
23
23
  class Error < T::Struct
24
24
  extend T::Sig
25
25
 
26
+ # A prop marked `override` needs the method it implements to exist already
27
+ include LogStruct::Log::Interfaces::CommonFields
28
+
26
29
  # Shared/common fields
27
- const :source, Source::Job, default: Source::Job
28
- const :event, Event, default: Event::Error
29
- const :timestamp, Time, factory: -> { Time.now }
30
- const :level, Level, default: Level::Info
30
+ const :source, Source::Job, default: Source::Job, override: true
31
+ const :event, Event, default: Event::Error, override: true
32
+ const :timestamp, Time, factory: -> { Time.now }, override: true
33
+ const :level, Level, default: Level::Info, override: true
31
34
 
32
35
  const :job_id, String
33
36
  const :job_class, String
@@ -42,7 +45,6 @@ module LogStruct
42
45
  const :backtrace, T.nilable(T::Array[String]), default: nil
43
46
 
44
47
  # Serialize shared fields
45
- include LogStruct::Log::Interfaces::CommonFields
46
48
  include LogStruct::Log::Shared::SerializeCommon
47
49
 
48
50
  sig { returns(T::Hash[LogStruct::LogField, T.untyped]) }
@@ -23,11 +23,14 @@ module LogStruct
23
23
  class Finish < T::Struct
24
24
  extend T::Sig
25
25
 
26
+ # A prop marked `override` needs the method it implements to exist already
27
+ include LogStruct::Log::Interfaces::CommonFields
28
+
26
29
  # Shared/common fields
27
- const :source, Source::Job, default: Source::Job
28
- const :event, Event, default: Event::Finish
29
- const :timestamp, Time, factory: -> { Time.now }
30
- const :level, Level, default: Level::Info
30
+ const :source, Source::Job, default: Source::Job, override: true
31
+ const :event, Event, default: Event::Finish, override: true
32
+ const :timestamp, Time, factory: -> { Time.now }, override: true
33
+ const :level, Level, default: Level::Info, override: true
31
34
 
32
35
  const :job_id, String
33
36
  const :job_class, String
@@ -41,7 +44,6 @@ module LogStruct
41
44
  const :finished_at, Time
42
45
 
43
46
  # Serialize shared fields
44
- include LogStruct::Log::Interfaces::CommonFields
45
47
  include LogStruct::Log::Shared::SerializeCommon
46
48
 
47
49
  sig { returns(T::Hash[LogStruct::LogField, T.untyped]) }
@@ -23,11 +23,14 @@ module LogStruct
23
23
  class Retry < T::Struct
24
24
  extend T::Sig
25
25
 
26
+ # A prop marked `override` needs the method it implements to exist already
27
+ include LogStruct::Log::Interfaces::CommonFields
28
+
26
29
  # Shared/common fields
27
- const :source, Source::Job, default: Source::Job
28
- const :event, Event, default: Event::Retry
29
- const :timestamp, Time, factory: -> { Time.now }
30
- const :level, Level, default: Level::Info
30
+ const :source, Source::Job, default: Source::Job, override: true
31
+ const :event, Event, default: Event::Retry, override: true
32
+ const :timestamp, Time, factory: -> { Time.now }, override: true
33
+ const :level, Level, default: Level::Info, override: true
31
34
 
32
35
  const :job_id, String
33
36
  const :job_class, String
@@ -42,7 +45,6 @@ module LogStruct
42
45
  const :wait_ms, T.nilable(Float), default: nil
43
46
 
44
47
  # Serialize shared fields
45
- include LogStruct::Log::Interfaces::CommonFields
46
48
  include LogStruct::Log::Shared::SerializeCommon
47
49
 
48
50
  sig { returns(T::Hash[LogStruct::LogField, T.untyped]) }
@@ -23,11 +23,14 @@ module LogStruct
23
23
  class RetryStopped < T::Struct
24
24
  extend T::Sig
25
25
 
26
+ # A prop marked `override` needs the method it implements to exist already
27
+ include LogStruct::Log::Interfaces::CommonFields
28
+
26
29
  # Shared/common fields
27
- const :source, Source::Job, default: Source::Job
28
- const :event, Event, default: Event::RetryStopped
29
- const :timestamp, Time, factory: -> { Time.now }
30
- const :level, Level, default: Level::Info
30
+ const :source, Source::Job, default: Source::Job, override: true
31
+ const :event, Event, default: Event::RetryStopped, override: true
32
+ const :timestamp, Time, factory: -> { Time.now }, override: true
33
+ const :level, Level, default: Level::Info, override: true
31
34
 
32
35
  const :job_id, String
33
36
  const :job_class, String
@@ -41,7 +44,6 @@ module LogStruct
41
44
  const :message, String
42
45
 
43
46
  # Serialize shared fields
44
- include LogStruct::Log::Interfaces::CommonFields
45
47
  include LogStruct::Log::Shared::SerializeCommon
46
48
 
47
49
  sig { returns(T::Hash[LogStruct::LogField, T.untyped]) }
@@ -23,11 +23,14 @@ module LogStruct
23
23
  class Schedule < T::Struct
24
24
  extend T::Sig
25
25
 
26
+ # A prop marked `override` needs the method it implements to exist already
27
+ include LogStruct::Log::Interfaces::CommonFields
28
+
26
29
  # Shared/common fields
27
- const :source, Source::Job, default: Source::Job
28
- const :event, Event, default: Event::Schedule
29
- const :timestamp, Time, factory: -> { Time.now }
30
- const :level, Level, default: Level::Info
30
+ const :source, Source::Job, default: Source::Job, override: true
31
+ const :event, Event, default: Event::Schedule, override: true
32
+ const :timestamp, Time, factory: -> { Time.now }, override: true
33
+ const :level, Level, default: Level::Info, override: true
31
34
 
32
35
  const :job_id, String
33
36
  const :job_class, String
@@ -40,7 +43,6 @@ module LogStruct
40
43
  const :scheduled_at, Time
41
44
 
42
45
  # Serialize shared fields
43
- include LogStruct::Log::Interfaces::CommonFields
44
46
  include LogStruct::Log::Shared::SerializeCommon
45
47
 
46
48
  sig { returns(T::Hash[LogStruct::LogField, T.untyped]) }
@@ -23,11 +23,14 @@ module LogStruct
23
23
  class Start < T::Struct
24
24
  extend T::Sig
25
25
 
26
+ # A prop marked `override` needs the method it implements to exist already
27
+ include LogStruct::Log::Interfaces::CommonFields
28
+
26
29
  # Shared/common fields
27
- const :source, Source::Job, default: Source::Job
28
- const :event, Event, default: Event::Start
29
- const :timestamp, Time, factory: -> { Time.now }
30
- const :level, Level, default: Level::Info
30
+ const :source, Source::Job, default: Source::Job, override: true
31
+ const :event, Event, default: Event::Start, override: true
32
+ const :timestamp, Time, factory: -> { Time.now }, override: true
33
+ const :level, Level, default: Level::Info, override: true
31
34
 
32
35
  const :job_id, String
33
36
  const :job_class, String
@@ -41,7 +44,6 @@ module LogStruct
41
44
  const :attempt, T.nilable(Integer), default: nil
42
45
 
43
46
  # Serialize shared fields
44
- include LogStruct::Log::Interfaces::CommonFields
45
47
  include LogStruct::Log::Shared::SerializeCommon
46
48
 
47
49
  sig { returns(T::Hash[LogStruct::LogField, T.untyped]) }
@@ -20,6 +20,7 @@ module LogStruct
20
20
  class ActiveJob
21
21
  class BaseFields < T::Struct
22
22
  extend T::Sig
23
+
23
24
  const :job_id, String
24
25
  const :job_class, String
25
26
  const :queue_name, T.nilable(Symbol), default: nil
@@ -22,11 +22,14 @@ module LogStruct
22
22
  class ActiveModelSerializers < T::Struct
23
23
  extend T::Sig
24
24
 
25
+ # A prop marked `override` needs the method it implements to exist already
26
+ include LogStruct::Log::Interfaces::CommonFields
27
+
25
28
  # Shared/common fields
26
- const :source, Source::Rails, default: Source::Rails
27
- const :event, Event, default: Event::Generate
28
- const :timestamp, Time, factory: -> { Time.now }
29
- const :level, Level, default: Level::Info
29
+ const :source, Source::Rails, default: Source::Rails, override: true
30
+ const :event, Event, default: Event::Generate, override: true
31
+ const :timestamp, Time, factory: -> { Time.now }, override: true
32
+ const :level, Level, default: Level::Info, override: true
30
33
 
31
34
  # Event-specific fields
32
35
  const :message, String
@@ -36,7 +39,6 @@ module LogStruct
36
39
  const :duration_ms, Float
37
40
 
38
41
  # Serialize shared fields
39
- include LogStruct::Log::Interfaces::CommonFields
40
42
  include LogStruct::Log::Shared::SerializeCommon
41
43
 
42
44
  sig { returns(T::Hash[LogStruct::LogField, T.untyped]) }
@@ -23,11 +23,14 @@ module LogStruct
23
23
  class Delete < T::Struct
24
24
  extend T::Sig
25
25
 
26
+ # A prop marked `override` needs the method it implements to exist already
27
+ include LogStruct::Log::Interfaces::CommonFields
28
+
26
29
  # Shared/common fields
27
- const :source, Source::Storage, default: Source::Storage
28
- const :event, Event, default: Event::Delete
29
- const :timestamp, Time, factory: -> { Time.now }
30
- const :level, Level, default: Level::Info
30
+ const :source, Source::Storage, default: Source::Storage, override: true
31
+ const :event, Event, default: Event::Delete, override: true
32
+ const :timestamp, Time, factory: -> { Time.now }, override: true
33
+ const :level, Level, default: Level::Info, override: true
31
34
 
32
35
  const :storage, Symbol
33
36
  const :file_id, T.nilable(String), default: nil
@@ -36,7 +39,6 @@ module LogStruct
36
39
  const :prefix, T.nilable(String), default: nil
37
40
 
38
41
  # Serialize shared fields
39
- include LogStruct::Log::Interfaces::CommonFields
40
42
  include LogStruct::Log::Shared::SerializeCommon
41
43
 
42
44
  sig { returns(T::Hash[LogStruct::LogField, T.untyped]) }
@@ -23,11 +23,14 @@ module LogStruct
23
23
  class Download < T::Struct
24
24
  extend T::Sig
25
25
 
26
+ # A prop marked `override` needs the method it implements to exist already
27
+ include LogStruct::Log::Interfaces::CommonFields
28
+
26
29
  # Shared/common fields
27
- const :source, Source::Storage, default: Source::Storage
28
- const :event, Event, default: Event::Download
29
- const :timestamp, Time, factory: -> { Time.now }
30
- const :level, Level, default: Level::Info
30
+ const :source, Source::Storage, default: Source::Storage, override: true
31
+ const :event, Event, default: Event::Download, override: true
32
+ const :timestamp, Time, factory: -> { Time.now }, override: true
33
+ const :level, Level, default: Level::Info, override: true
31
34
 
32
35
  const :storage, Symbol
33
36
  const :file_id, T.nilable(String), default: nil
@@ -37,7 +40,6 @@ module LogStruct
37
40
  const :duration_ms, T.nilable(Float), default: nil
38
41
 
39
42
  # Serialize shared fields
40
- include LogStruct::Log::Interfaces::CommonFields
41
43
  include LogStruct::Log::Shared::SerializeCommon
42
44
 
43
45
  sig { returns(T::Hash[LogStruct::LogField, T.untyped]) }
@@ -23,11 +23,14 @@ module LogStruct
23
23
  class Exist < T::Struct
24
24
  extend T::Sig
25
25
 
26
+ # A prop marked `override` needs the method it implements to exist already
27
+ include LogStruct::Log::Interfaces::CommonFields
28
+
26
29
  # Shared/common fields
27
- const :source, Source::Storage, default: Source::Storage
28
- const :event, Event, default: Event::Exist
29
- const :timestamp, Time, factory: -> { Time.now }
30
- const :level, Level, default: Level::Info
30
+ const :source, Source::Storage, default: Source::Storage, override: true
31
+ const :event, Event, default: Event::Exist, override: true
32
+ const :timestamp, Time, factory: -> { Time.now }, override: true
33
+ const :level, Level, default: Level::Info, override: true
31
34
 
32
35
  const :storage, Symbol
33
36
  const :file_id, T.nilable(String), default: nil
@@ -36,7 +39,6 @@ module LogStruct
36
39
  const :exist, T.nilable(T::Boolean), default: nil
37
40
 
38
41
  # Serialize shared fields
39
- include LogStruct::Log::Interfaces::CommonFields
40
42
  include LogStruct::Log::Shared::SerializeCommon
41
43
 
42
44
  sig { returns(T::Hash[LogStruct::LogField, T.untyped]) }