logstruct 0.1.0 → 0.1.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 +4 -4
- data/CHANGELOG.md +5 -1
- data/README.md +15 -2
- data/lib/log_struct/boot_buffer.rb +28 -0
- data/lib/log_struct/builders/active_job.rb +84 -0
- data/lib/log_struct/concerns/configuration.rb +126 -13
- data/lib/log_struct/concerns/error_handling.rb +3 -7
- data/lib/log_struct/config_struct/filters.rb +18 -0
- data/lib/log_struct/config_struct/integrations.rb +8 -12
- data/lib/log_struct/configuration.rb +13 -0
- data/lib/log_struct/enums/event.rb +13 -0
- data/lib/log_struct/enums/log_field.rb +154 -0
- data/lib/log_struct/enums/source.rb +4 -1
- data/lib/log_struct/formatter.rb +29 -17
- data/lib/log_struct/integrations/action_mailer/error_handling.rb +3 -11
- data/lib/log_struct/integrations/action_mailer/event_logging.rb +22 -12
- data/lib/log_struct/integrations/active_job/log_subscriber.rb +52 -48
- data/lib/log_struct/integrations/active_model_serializers.rb +8 -14
- data/lib/log_struct/integrations/active_record.rb +35 -5
- data/lib/log_struct/integrations/active_storage.rb +59 -20
- data/lib/log_struct/integrations/ahoy.rb +2 -1
- data/lib/log_struct/integrations/carrierwave.rb +13 -16
- data/lib/log_struct/integrations/dotenv.rb +278 -0
- data/lib/log_struct/integrations/good_job/log_subscriber.rb +86 -136
- data/lib/log_struct/integrations/good_job/logger.rb +8 -10
- data/lib/log_struct/integrations/good_job.rb +5 -7
- data/lib/log_struct/integrations/host_authorization.rb +25 -4
- data/lib/log_struct/integrations/lograge.rb +20 -14
- data/lib/log_struct/integrations/puma.rb +482 -0
- data/lib/log_struct/integrations/rack_error_handler/middleware.rb +11 -18
- data/lib/log_struct/integrations/shrine.rb +44 -19
- data/lib/log_struct/integrations/sorbet.rb +48 -0
- data/lib/log_struct/integrations.rb +21 -0
- data/lib/log_struct/log/action_mailer/delivered.rb +99 -0
- data/lib/log_struct/log/action_mailer/delivery.rb +99 -0
- data/lib/log_struct/log/action_mailer.rb +30 -45
- data/lib/log_struct/log/active_job/enqueue.rb +125 -0
- data/lib/log_struct/log/active_job/finish.rb +130 -0
- data/lib/log_struct/log/active_job/schedule.rb +125 -0
- data/lib/log_struct/log/active_job/start.rb +130 -0
- data/lib/log_struct/log/active_job.rb +41 -54
- data/lib/log_struct/log/active_model_serializers.rb +72 -33
- data/lib/log_struct/log/active_storage/delete.rb +87 -0
- data/lib/log_struct/log/active_storage/download.rb +103 -0
- data/lib/log_struct/log/active_storage/exist.rb +93 -0
- data/lib/log_struct/log/active_storage/metadata.rb +93 -0
- data/lib/log_struct/log/active_storage/stream.rb +93 -0
- data/lib/log_struct/log/active_storage/upload.rb +118 -0
- data/lib/log_struct/log/active_storage/url.rb +93 -0
- data/lib/log_struct/log/active_storage.rb +32 -68
- data/lib/log_struct/log/ahoy.rb +67 -33
- data/lib/log_struct/log/carrierwave/delete.rb +115 -0
- data/lib/log_struct/log/carrierwave/download.rb +131 -0
- data/lib/log_struct/log/carrierwave/upload.rb +141 -0
- data/lib/log_struct/log/carrierwave.rb +37 -72
- data/lib/log_struct/log/dotenv/load.rb +76 -0
- data/lib/log_struct/log/dotenv/restore.rb +76 -0
- data/lib/log_struct/log/dotenv/save.rb +76 -0
- data/lib/log_struct/log/dotenv/update.rb +76 -0
- data/lib/log_struct/log/dotenv.rb +12 -0
- data/lib/log_struct/log/error.rb +58 -47
- data/lib/log_struct/log/good_job/enqueue.rb +126 -0
- data/lib/log_struct/log/good_job/error.rb +151 -0
- data/lib/log_struct/log/good_job/finish.rb +136 -0
- data/lib/log_struct/log/good_job/log.rb +131 -0
- data/lib/log_struct/log/good_job/schedule.rb +136 -0
- data/lib/log_struct/log/good_job/start.rb +136 -0
- data/lib/log_struct/log/good_job.rb +40 -141
- data/lib/log_struct/log/interfaces/additional_data_field.rb +1 -17
- data/lib/log_struct/log/interfaces/common_fields.rb +1 -39
- data/lib/log_struct/log/interfaces/public_common_fields.rb +1 -28
- data/lib/log_struct/log/interfaces/request_fields.rb +1 -33
- data/lib/log_struct/log/plain.rb +59 -34
- data/lib/log_struct/log/puma/shutdown.rb +80 -0
- data/lib/log_struct/log/puma/start.rb +120 -0
- data/lib/log_struct/log/puma.rb +10 -0
- data/lib/log_struct/log/request.rb +132 -48
- data/lib/log_struct/log/security/blocked_host.rb +141 -0
- data/lib/log_struct/log/security/csrf_violation.rb +131 -0
- data/lib/log_struct/log/security/ip_spoof.rb +141 -0
- data/lib/log_struct/log/security.rb +40 -70
- data/lib/log_struct/log/shared/add_request_fields.rb +1 -26
- data/lib/log_struct/log/shared/merge_additional_data_fields.rb +1 -22
- data/lib/log_struct/log/shared/serialize_common.rb +1 -33
- data/lib/log_struct/log/shared/serialize_common_public.rb +9 -9
- data/lib/log_struct/log/shrine/delete.rb +85 -0
- data/lib/log_struct/log/shrine/download.rb +90 -0
- data/lib/log_struct/log/shrine/exist.rb +90 -0
- data/lib/log_struct/log/shrine/metadata.rb +90 -0
- data/lib/log_struct/log/shrine/upload.rb +105 -0
- data/lib/log_struct/log/shrine.rb +10 -67
- data/lib/log_struct/log/sidekiq.rb +65 -26
- data/lib/log_struct/log/sql.rb +113 -106
- data/lib/log_struct/log.rb +29 -36
- data/lib/log_struct/multi_error_reporter.rb +80 -22
- data/lib/log_struct/param_filters.rb +50 -7
- data/lib/log_struct/rails_boot_banner_silencer.rb +123 -0
- data/lib/log_struct/railtie.rb +71 -0
- data/lib/log_struct/semantic_logger/formatter.rb +4 -2
- data/lib/log_struct/semantic_logger/setup.rb +34 -18
- data/lib/log_struct/shared/interfaces/additional_data_field.rb +22 -0
- data/lib/log_struct/shared/interfaces/common_fields.rb +39 -0
- data/lib/log_struct/shared/interfaces/public_common_fields.rb +29 -0
- data/lib/log_struct/shared/interfaces/request_fields.rb +39 -0
- data/lib/log_struct/shared/shared/add_request_fields.rb +28 -0
- data/lib/log_struct/shared/shared/merge_additional_data_fields.rb +27 -0
- data/lib/log_struct/shared/shared/serialize_common.rb +58 -0
- data/lib/log_struct/version.rb +1 -1
- data/lib/log_struct.rb +22 -4
- data/logstruct.gemspec +2 -1
- metadata +78 -9
- data/lib/log_struct/log/interfaces/message_field.rb +0 -20
- data/lib/log_struct/log_keys.rb +0 -102
@@ -1,79 +1,49 @@
|
|
1
1
|
# typed: strict
|
2
2
|
# frozen_string_literal: true
|
3
3
|
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
require_relative "
|
10
|
-
require_relative "
|
11
|
-
require_relative "
|
12
|
-
require_relative "../enums/level"
|
13
|
-
require_relative "../enums/source"
|
14
|
-
require_relative "../log_keys"
|
4
|
+
# AUTO-GENERATED: DO NOT EDIT
|
5
|
+
# Generated by scripts/generate_structs.rb
|
6
|
+
# Schemas dir: schemas/log_sources/
|
7
|
+
# Template: tools/codegen/templates/sorbet/source_parent.rb.erb
|
8
|
+
|
9
|
+
require_relative "security/ip_spoof"
|
10
|
+
require_relative "security/csrf_violation"
|
11
|
+
require_relative "security/blocked_host"
|
15
12
|
|
16
13
|
module LogStruct
|
17
14
|
module Log
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
# Additional data (merged into hash)
|
52
|
-
const :additional_data, T::Hash[Symbol, T.untyped], default: {}
|
53
|
-
|
54
|
-
# Common request fields
|
55
|
-
const :path, T.nilable(String), default: nil
|
56
|
-
const :http_method, T.nilable(String), default: nil, name: "method"
|
57
|
-
const :source_ip, T.nilable(String), default: nil
|
58
|
-
const :user_agent, T.nilable(String), default: nil
|
59
|
-
const :referer, T.nilable(String), default: nil
|
60
|
-
const :request_id, T.nilable(String), default: nil
|
61
|
-
|
62
|
-
# Convert the log entry to a hash for serialization
|
63
|
-
sig { override.params(strict: T::Boolean).returns(T::Hash[Symbol, T.untyped]) }
|
64
|
-
def serialize(strict = true)
|
65
|
-
hash = serialize_common(strict)
|
66
|
-
add_request_fields(hash)
|
67
|
-
merge_additional_data_fields(hash)
|
68
|
-
|
69
|
-
# Add security-specific fields
|
70
|
-
hash[LOG_KEYS.fetch(:message)] = message if message
|
71
|
-
hash[LOG_KEYS.fetch(:blocked_host)] = blocked_host if blocked_host
|
72
|
-
hash[LOG_KEYS.fetch(:blocked_hosts)] = blocked_hosts if blocked_hosts
|
73
|
-
hash[LOG_KEYS.fetch(:client_ip)] = client_ip if client_ip
|
74
|
-
hash[LOG_KEYS.fetch(:x_forwarded_for)] = x_forwarded_for if x_forwarded_for
|
75
|
-
|
76
|
-
hash
|
15
|
+
class Security
|
16
|
+
class BaseFields < T::Struct
|
17
|
+
extend T::Sig
|
18
|
+
const :path, T.nilable(String), default: nil
|
19
|
+
const :http_method, T.nilable(String), default: nil
|
20
|
+
const :source_ip, T.nilable(String), default: nil
|
21
|
+
const :user_agent, T.nilable(String), default: nil
|
22
|
+
const :referer, T.nilable(String), default: nil
|
23
|
+
const :request_id, T.nilable(String), default: nil
|
24
|
+
|
25
|
+
Kwargs = T.type_alias do
|
26
|
+
{
|
27
|
+
path: T.nilable(String),
|
28
|
+
http_method: T.nilable(String),
|
29
|
+
source_ip: T.nilable(String),
|
30
|
+
user_agent: T.nilable(String),
|
31
|
+
referer: T.nilable(String),
|
32
|
+
request_id: T.nilable(String)
|
33
|
+
}
|
34
|
+
end
|
35
|
+
|
36
|
+
sig { returns(Kwargs) }
|
37
|
+
def to_kwargs
|
38
|
+
{
|
39
|
+
path: path,
|
40
|
+
http_method: http_method,
|
41
|
+
source_ip: source_ip,
|
42
|
+
user_agent: user_agent,
|
43
|
+
referer: referer,
|
44
|
+
request_id: request_id
|
45
|
+
}
|
46
|
+
end
|
77
47
|
end
|
78
48
|
end
|
79
49
|
end
|
@@ -1,29 +1,4 @@
|
|
1
1
|
# typed: strict
|
2
2
|
# frozen_string_literal: true
|
3
3
|
|
4
|
-
|
5
|
-
require_relative "../interfaces/request_fields"
|
6
|
-
|
7
|
-
module LogStruct
|
8
|
-
module Log
|
9
|
-
# Common log serialization method
|
10
|
-
module AddRequestFields
|
11
|
-
extend T::Sig
|
12
|
-
extend T::Helpers
|
13
|
-
|
14
|
-
requires_ancestor { Interfaces::RequestFields }
|
15
|
-
|
16
|
-
# Helper method to serialize request fields
|
17
|
-
sig { params(hash: T::Hash[Symbol, T.untyped]).void }
|
18
|
-
def add_request_fields(hash)
|
19
|
-
# Add request-specific fields if they're present
|
20
|
-
hash[LOG_KEYS.fetch(:path)] = path if path
|
21
|
-
hash[LOG_KEYS.fetch(:http_method)] = http_method if http_method # Use `method` in JSON
|
22
|
-
hash[LOG_KEYS.fetch(:source_ip)] = source_ip if source_ip
|
23
|
-
hash[LOG_KEYS.fetch(:user_agent)] = user_agent if user_agent
|
24
|
-
hash[LOG_KEYS.fetch(:referer)] = referer if referer
|
25
|
-
hash[LOG_KEYS.fetch(:request_id)] = request_id if request_id
|
26
|
-
end
|
27
|
-
end
|
28
|
-
end
|
29
|
-
end
|
4
|
+
require "log_struct/shared/shared/add_request_fields"
|
@@ -1,25 +1,4 @@
|
|
1
1
|
# typed: strict
|
2
2
|
# frozen_string_literal: true
|
3
3
|
|
4
|
-
|
5
|
-
require_relative "../interfaces/additional_data_field"
|
6
|
-
|
7
|
-
module LogStruct
|
8
|
-
module Log
|
9
|
-
# Helper module for merging additional data into serialized logs
|
10
|
-
module MergeAdditionalDataFields
|
11
|
-
extend T::Sig
|
12
|
-
extend T::Helpers
|
13
|
-
|
14
|
-
requires_ancestor { T::Struct }
|
15
|
-
requires_ancestor { Interfaces::AdditionalDataField }
|
16
|
-
|
17
|
-
sig { params(hash: T::Hash[Symbol, T.untyped]).void }
|
18
|
-
def merge_additional_data_fields(hash)
|
19
|
-
additional_data.each do |key, value|
|
20
|
-
hash[key.to_sym] = value
|
21
|
-
end
|
22
|
-
end
|
23
|
-
end
|
24
|
-
end
|
25
|
-
end
|
4
|
+
require "log_struct/shared/shared/merge_additional_data_fields"
|
@@ -1,36 +1,4 @@
|
|
1
1
|
# typed: strict
|
2
2
|
# frozen_string_literal: true
|
3
3
|
|
4
|
-
|
5
|
-
require_relative "../interfaces/common_fields"
|
6
|
-
|
7
|
-
module LogStruct
|
8
|
-
module Log
|
9
|
-
# Common log serialization method
|
10
|
-
module SerializeCommon
|
11
|
-
extend T::Sig
|
12
|
-
extend T::Helpers
|
13
|
-
|
14
|
-
requires_ancestor { Interfaces::CommonFields }
|
15
|
-
|
16
|
-
# Convert the log entry to a hash for serialization.
|
17
|
-
# (strict param is unused, but need same signature as default T::Struct.serialize)
|
18
|
-
sig { params(strict: T::Boolean).returns(T::Hash[Symbol, T.untyped]) }
|
19
|
-
def serialize_common(strict = true)
|
20
|
-
{
|
21
|
-
LOG_KEYS.fetch(:source) => source.serialize.to_s,
|
22
|
-
LOG_KEYS.fetch(:event) => event.serialize.to_s,
|
23
|
-
LOG_KEYS.fetch(:level) => level.serialize.to_s,
|
24
|
-
LOG_KEYS.fetch(:timestamp) => timestamp.iso8601(3)
|
25
|
-
}
|
26
|
-
end
|
27
|
-
|
28
|
-
# Override as_json to use our custom serialize method instead of default T::Struct serialization
|
29
|
-
sig { params(options: T.untyped).returns(T::Hash[String, T.untyped]) }
|
30
|
-
def as_json(options = nil)
|
31
|
-
# Convert symbol keys to strings for JSON
|
32
|
-
serialize.transform_keys(&:to_s)
|
33
|
-
end
|
34
|
-
end
|
35
|
-
end
|
36
|
-
end
|
4
|
+
require "log_struct/shared/shared/serialize_common"
|
@@ -1,7 +1,7 @@
|
|
1
1
|
# typed: strict
|
2
2
|
# frozen_string_literal: true
|
3
3
|
|
4
|
-
require_relative "../../
|
4
|
+
require_relative "../../enums/log_field"
|
5
5
|
require_relative "../interfaces/public_common_fields"
|
6
6
|
|
7
7
|
module LogStruct
|
@@ -20,18 +20,18 @@ module LogStruct
|
|
20
20
|
raise ArgumentError, "Public log struct must define #source and #event"
|
21
21
|
end
|
22
22
|
|
23
|
-
src_val =
|
24
|
-
evt_val =
|
25
|
-
src = src_val.respond_to?(:serialize) ?
|
26
|
-
evt = evt_val.respond_to?(:serialize) ?
|
23
|
+
src_val = public_send(:source)
|
24
|
+
evt_val = public_send(:event)
|
25
|
+
src = src_val.respond_to?(:serialize) ? src_val.public_send(:serialize).to_s : src_val.to_s
|
26
|
+
evt = evt_val.respond_to?(:serialize) ? evt_val.public_send(:serialize).to_s : evt_val.to_s
|
27
27
|
lvl = level.serialize.to_s
|
28
28
|
ts = timestamp.iso8601(3)
|
29
29
|
|
30
30
|
{
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
31
|
+
LogField::Source.serialize => src,
|
32
|
+
LogField::Event.serialize => evt,
|
33
|
+
LogField::Level.serialize => lvl,
|
34
|
+
LogField::Timestamp.serialize => ts
|
35
35
|
}
|
36
36
|
end
|
37
37
|
|
@@ -0,0 +1,85 @@
|
|
1
|
+
# typed: strict
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
4
|
+
# AUTO-GENERATED: DO NOT EDIT
|
5
|
+
# Generated by scripts/generate_structs.rb
|
6
|
+
# Schemas dir: schemas/log_sources/
|
7
|
+
# Template: tools/codegen/templates/sorbet/event.rb.erb
|
8
|
+
|
9
|
+
require "log_struct/shared/interfaces/common_fields"
|
10
|
+
require "log_struct/shared/interfaces/additional_data_field"
|
11
|
+
require "log_struct/shared/interfaces/request_fields"
|
12
|
+
require "log_struct/shared/shared/serialize_common"
|
13
|
+
require "log_struct/shared/shared/merge_additional_data_fields"
|
14
|
+
require "log_struct/shared/shared/add_request_fields"
|
15
|
+
require_relative "../../enums/source"
|
16
|
+
require_relative "../../enums/event"
|
17
|
+
require_relative "../../enums/level"
|
18
|
+
require_relative "../../enums/log_field"
|
19
|
+
|
20
|
+
module LogStruct
|
21
|
+
module Log
|
22
|
+
class Shrine
|
23
|
+
class Delete < T::Struct
|
24
|
+
# typed: strict
|
25
|
+
# frozen_string_literal: true
|
26
|
+
|
27
|
+
extend T::Sig
|
28
|
+
|
29
|
+
extend T::Sig
|
30
|
+
|
31
|
+
# Shared/common fields
|
32
|
+
const :source, Source::Shrine, default: Source::Shrine
|
33
|
+
const :event, Event, default: Event::Delete
|
34
|
+
const :timestamp, Time, factory: -> { Time.now }
|
35
|
+
const :level, Level, default: Level::Info
|
36
|
+
|
37
|
+
# Event-specific fields
|
38
|
+
const :storage, String
|
39
|
+
const :location, String
|
40
|
+
|
41
|
+
# Additional data
|
42
|
+
include LogStruct::Log::Interfaces::AdditionalDataField
|
43
|
+
const :additional_data, T.nilable(T::Hash[T.any(String, Symbol), T.untyped]), default: nil
|
44
|
+
include LogStruct::Log::Shared::MergeAdditionalDataFields
|
45
|
+
|
46
|
+
# Request fields (optional)
|
47
|
+
|
48
|
+
# Serialize shared fields
|
49
|
+
include LogStruct::Log::Interfaces::CommonFields
|
50
|
+
include LogStruct::Log::Shared::SerializeCommon
|
51
|
+
|
52
|
+
sig { returns(T::Hash[LogStruct::LogField, T.untyped]) }
|
53
|
+
def self.base_hash
|
54
|
+
{}
|
55
|
+
end
|
56
|
+
|
57
|
+
sig {
|
58
|
+
params(storage: T.untyped,
|
59
|
+
location: T.untyped,
|
60
|
+
additional_data: T.untyped,
|
61
|
+
timestamp: T.untyped).returns(T::Hash[LogStruct::LogField, T.untyped])
|
62
|
+
}
|
63
|
+
def self.build(storage:,
|
64
|
+
location:,
|
65
|
+
additional_data: nil,
|
66
|
+
timestamp: Time.now)
|
67
|
+
h = base_hash
|
68
|
+
h[LogField::Storage] = storage
|
69
|
+
h[LogField::Location] = location
|
70
|
+
h
|
71
|
+
end
|
72
|
+
|
73
|
+
sig { returns(T::Hash[LogStruct::LogField, T.untyped]) }
|
74
|
+
def to_h
|
75
|
+
self.class.build(
|
76
|
+
storage: storage,
|
77
|
+
location: location,
|
78
|
+
additional_data: additional_data,
|
79
|
+
timestamp: timestamp
|
80
|
+
)
|
81
|
+
end
|
82
|
+
end
|
83
|
+
end
|
84
|
+
end
|
85
|
+
end
|
@@ -0,0 +1,90 @@
|
|
1
|
+
# typed: strict
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
4
|
+
# AUTO-GENERATED: DO NOT EDIT
|
5
|
+
# Generated by scripts/generate_structs.rb
|
6
|
+
# Schemas dir: schemas/log_sources/
|
7
|
+
# Template: tools/codegen/templates/sorbet/event.rb.erb
|
8
|
+
|
9
|
+
require "log_struct/shared/interfaces/common_fields"
|
10
|
+
require "log_struct/shared/interfaces/additional_data_field"
|
11
|
+
require "log_struct/shared/interfaces/request_fields"
|
12
|
+
require "log_struct/shared/shared/serialize_common"
|
13
|
+
require "log_struct/shared/shared/merge_additional_data_fields"
|
14
|
+
require "log_struct/shared/shared/add_request_fields"
|
15
|
+
require_relative "../../enums/source"
|
16
|
+
require_relative "../../enums/event"
|
17
|
+
require_relative "../../enums/level"
|
18
|
+
require_relative "../../enums/log_field"
|
19
|
+
|
20
|
+
module LogStruct
|
21
|
+
module Log
|
22
|
+
class Shrine
|
23
|
+
class Download < T::Struct
|
24
|
+
# typed: strict
|
25
|
+
# frozen_string_literal: true
|
26
|
+
|
27
|
+
extend T::Sig
|
28
|
+
|
29
|
+
extend T::Sig
|
30
|
+
|
31
|
+
# Shared/common fields
|
32
|
+
const :source, Source::Shrine, default: Source::Shrine
|
33
|
+
const :event, Event, default: Event::Download
|
34
|
+
const :timestamp, Time, factory: -> { Time.now }
|
35
|
+
const :level, Level, default: Level::Info
|
36
|
+
|
37
|
+
# Event-specific fields
|
38
|
+
const :storage, String
|
39
|
+
const :location, String
|
40
|
+
const :download_options, T.nilable(T::Hash[Symbol, T.untyped]), default: nil
|
41
|
+
|
42
|
+
# Additional data
|
43
|
+
include LogStruct::Log::Interfaces::AdditionalDataField
|
44
|
+
const :additional_data, T.nilable(T::Hash[T.any(String, Symbol), T.untyped]), default: nil
|
45
|
+
include LogStruct::Log::Shared::MergeAdditionalDataFields
|
46
|
+
|
47
|
+
# Request fields (optional)
|
48
|
+
|
49
|
+
# Serialize shared fields
|
50
|
+
include LogStruct::Log::Interfaces::CommonFields
|
51
|
+
include LogStruct::Log::Shared::SerializeCommon
|
52
|
+
|
53
|
+
sig { returns(T::Hash[LogStruct::LogField, T.untyped]) }
|
54
|
+
def self.base_hash
|
55
|
+
{}
|
56
|
+
end
|
57
|
+
|
58
|
+
sig {
|
59
|
+
params(storage: T.untyped,
|
60
|
+
location: T.untyped,
|
61
|
+
download_options: T.untyped,
|
62
|
+
additional_data: T.untyped,
|
63
|
+
timestamp: T.untyped).returns(T::Hash[LogStruct::LogField, T.untyped])
|
64
|
+
}
|
65
|
+
def self.build(storage:,
|
66
|
+
location:,
|
67
|
+
download_options: nil,
|
68
|
+
additional_data: nil,
|
69
|
+
timestamp: Time.now)
|
70
|
+
h = base_hash
|
71
|
+
h[LogField::Storage] = storage
|
72
|
+
h[LogField::Location] = location
|
73
|
+
h[LogField::DownloadOptions] = download_options unless download_options.nil?
|
74
|
+
h
|
75
|
+
end
|
76
|
+
|
77
|
+
sig { returns(T::Hash[LogStruct::LogField, T.untyped]) }
|
78
|
+
def to_h
|
79
|
+
self.class.build(
|
80
|
+
storage: storage,
|
81
|
+
location: location,
|
82
|
+
download_options: download_options,
|
83
|
+
additional_data: additional_data,
|
84
|
+
timestamp: timestamp
|
85
|
+
)
|
86
|
+
end
|
87
|
+
end
|
88
|
+
end
|
89
|
+
end
|
90
|
+
end
|
@@ -0,0 +1,90 @@
|
|
1
|
+
# typed: strict
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
4
|
+
# AUTO-GENERATED: DO NOT EDIT
|
5
|
+
# Generated by scripts/generate_structs.rb
|
6
|
+
# Schemas dir: schemas/log_sources/
|
7
|
+
# Template: tools/codegen/templates/sorbet/event.rb.erb
|
8
|
+
|
9
|
+
require "log_struct/shared/interfaces/common_fields"
|
10
|
+
require "log_struct/shared/interfaces/additional_data_field"
|
11
|
+
require "log_struct/shared/interfaces/request_fields"
|
12
|
+
require "log_struct/shared/shared/serialize_common"
|
13
|
+
require "log_struct/shared/shared/merge_additional_data_fields"
|
14
|
+
require "log_struct/shared/shared/add_request_fields"
|
15
|
+
require_relative "../../enums/source"
|
16
|
+
require_relative "../../enums/event"
|
17
|
+
require_relative "../../enums/level"
|
18
|
+
require_relative "../../enums/log_field"
|
19
|
+
|
20
|
+
module LogStruct
|
21
|
+
module Log
|
22
|
+
class Shrine
|
23
|
+
class Exist < T::Struct
|
24
|
+
# typed: strict
|
25
|
+
# frozen_string_literal: true
|
26
|
+
|
27
|
+
extend T::Sig
|
28
|
+
|
29
|
+
extend T::Sig
|
30
|
+
|
31
|
+
# Shared/common fields
|
32
|
+
const :source, Source::Shrine, default: Source::Shrine
|
33
|
+
const :event, Event, default: Event::Exist
|
34
|
+
const :timestamp, Time, factory: -> { Time.now }
|
35
|
+
const :level, Level, default: Level::Info
|
36
|
+
|
37
|
+
# Event-specific fields
|
38
|
+
const :storage, String
|
39
|
+
const :location, String
|
40
|
+
const :exist, T.nilable(T::Boolean), default: nil
|
41
|
+
|
42
|
+
# Additional data
|
43
|
+
include LogStruct::Log::Interfaces::AdditionalDataField
|
44
|
+
const :additional_data, T.nilable(T::Hash[T.any(String, Symbol), T.untyped]), default: nil
|
45
|
+
include LogStruct::Log::Shared::MergeAdditionalDataFields
|
46
|
+
|
47
|
+
# Request fields (optional)
|
48
|
+
|
49
|
+
# Serialize shared fields
|
50
|
+
include LogStruct::Log::Interfaces::CommonFields
|
51
|
+
include LogStruct::Log::Shared::SerializeCommon
|
52
|
+
|
53
|
+
sig { returns(T::Hash[LogStruct::LogField, T.untyped]) }
|
54
|
+
def self.base_hash
|
55
|
+
{}
|
56
|
+
end
|
57
|
+
|
58
|
+
sig {
|
59
|
+
params(storage: T.untyped,
|
60
|
+
location: T.untyped,
|
61
|
+
exist: T.untyped,
|
62
|
+
additional_data: T.untyped,
|
63
|
+
timestamp: T.untyped).returns(T::Hash[LogStruct::LogField, T.untyped])
|
64
|
+
}
|
65
|
+
def self.build(storage:,
|
66
|
+
location:,
|
67
|
+
exist: nil,
|
68
|
+
additional_data: nil,
|
69
|
+
timestamp: Time.now)
|
70
|
+
h = base_hash
|
71
|
+
h[LogField::Storage] = storage
|
72
|
+
h[LogField::Location] = location
|
73
|
+
h[LogField::Exist] = exist unless exist.nil?
|
74
|
+
h
|
75
|
+
end
|
76
|
+
|
77
|
+
sig { returns(T::Hash[LogStruct::LogField, T.untyped]) }
|
78
|
+
def to_h
|
79
|
+
self.class.build(
|
80
|
+
storage: storage,
|
81
|
+
location: location,
|
82
|
+
exist: exist,
|
83
|
+
additional_data: additional_data,
|
84
|
+
timestamp: timestamp
|
85
|
+
)
|
86
|
+
end
|
87
|
+
end
|
88
|
+
end
|
89
|
+
end
|
90
|
+
end
|
@@ -0,0 +1,90 @@
|
|
1
|
+
# typed: strict
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
4
|
+
# AUTO-GENERATED: DO NOT EDIT
|
5
|
+
# Generated by scripts/generate_structs.rb
|
6
|
+
# Schemas dir: schemas/log_sources/
|
7
|
+
# Template: tools/codegen/templates/sorbet/event.rb.erb
|
8
|
+
|
9
|
+
require "log_struct/shared/interfaces/common_fields"
|
10
|
+
require "log_struct/shared/interfaces/additional_data_field"
|
11
|
+
require "log_struct/shared/interfaces/request_fields"
|
12
|
+
require "log_struct/shared/shared/serialize_common"
|
13
|
+
require "log_struct/shared/shared/merge_additional_data_fields"
|
14
|
+
require "log_struct/shared/shared/add_request_fields"
|
15
|
+
require_relative "../../enums/source"
|
16
|
+
require_relative "../../enums/event"
|
17
|
+
require_relative "../../enums/level"
|
18
|
+
require_relative "../../enums/log_field"
|
19
|
+
|
20
|
+
module LogStruct
|
21
|
+
module Log
|
22
|
+
class Shrine
|
23
|
+
class Metadata < T::Struct
|
24
|
+
# typed: strict
|
25
|
+
# frozen_string_literal: true
|
26
|
+
|
27
|
+
extend T::Sig
|
28
|
+
|
29
|
+
extend T::Sig
|
30
|
+
|
31
|
+
# Shared/common fields
|
32
|
+
const :source, Source::Shrine, default: Source::Shrine
|
33
|
+
const :event, Event, default: Event::Metadata
|
34
|
+
const :timestamp, Time, factory: -> { Time.now }
|
35
|
+
const :level, Level, default: Level::Info
|
36
|
+
|
37
|
+
# Event-specific fields
|
38
|
+
const :storage, String
|
39
|
+
const :location, String
|
40
|
+
const :metadata, T.nilable(T::Hash[String, T.untyped]), default: nil
|
41
|
+
|
42
|
+
# Additional data
|
43
|
+
include LogStruct::Log::Interfaces::AdditionalDataField
|
44
|
+
const :additional_data, T.nilable(T::Hash[T.any(String, Symbol), T.untyped]), default: nil
|
45
|
+
include LogStruct::Log::Shared::MergeAdditionalDataFields
|
46
|
+
|
47
|
+
# Request fields (optional)
|
48
|
+
|
49
|
+
# Serialize shared fields
|
50
|
+
include LogStruct::Log::Interfaces::CommonFields
|
51
|
+
include LogStruct::Log::Shared::SerializeCommon
|
52
|
+
|
53
|
+
sig { returns(T::Hash[LogStruct::LogField, T.untyped]) }
|
54
|
+
def self.base_hash
|
55
|
+
{}
|
56
|
+
end
|
57
|
+
|
58
|
+
sig {
|
59
|
+
params(storage: T.untyped,
|
60
|
+
location: T.untyped,
|
61
|
+
metadata: T.untyped,
|
62
|
+
additional_data: T.untyped,
|
63
|
+
timestamp: T.untyped).returns(T::Hash[LogStruct::LogField, T.untyped])
|
64
|
+
}
|
65
|
+
def self.build(storage:,
|
66
|
+
location:,
|
67
|
+
metadata: nil,
|
68
|
+
additional_data: nil,
|
69
|
+
timestamp: Time.now)
|
70
|
+
h = base_hash
|
71
|
+
h[LogField::Storage] = storage
|
72
|
+
h[LogField::Location] = location
|
73
|
+
h[LogField::Metadata] = metadata unless metadata.nil?
|
74
|
+
h
|
75
|
+
end
|
76
|
+
|
77
|
+
sig { returns(T::Hash[LogStruct::LogField, T.untyped]) }
|
78
|
+
def to_h
|
79
|
+
self.class.build(
|
80
|
+
storage: storage,
|
81
|
+
location: location,
|
82
|
+
metadata: metadata,
|
83
|
+
additional_data: additional_data,
|
84
|
+
timestamp: timestamp
|
85
|
+
)
|
86
|
+
end
|
87
|
+
end
|
88
|
+
end
|
89
|
+
end
|
90
|
+
end
|