logstruct 0.1.0 → 0.1.2
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 +11 -1
- data/README.md +23 -3
- 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 +178 -15
- 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 +477 -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 +116 -0
- data/lib/log_struct/railtie.rb +67 -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 +36 -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,150 +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 "
|
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 "good_job/log"
|
10
|
+
require_relative "good_job/enqueue"
|
11
|
+
require_relative "good_job/start"
|
12
|
+
require_relative "good_job/finish"
|
13
|
+
require_relative "good_job/error"
|
14
|
+
require_relative "good_job/schedule"
|
12
15
|
|
13
16
|
module LogStruct
|
14
17
|
module Log
|
15
|
-
|
16
|
-
|
17
|
-
|
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
|
-
# event: Event::Error,
|
45
|
-
# job_id: "job_123",
|
46
|
-
# error_class: "StandardError",
|
47
|
-
# error_message: "Connection failed"
|
48
|
-
# )
|
49
|
-
# ```
|
50
|
-
class GoodJob < T::Struct
|
51
|
-
extend T::Sig
|
52
|
-
|
53
|
-
include Interfaces::CommonFields
|
54
|
-
include Interfaces::AdditionalDataField
|
55
|
-
include SerializeCommon
|
56
|
-
include MergeAdditionalDataFields
|
57
|
-
|
58
|
-
# Valid event types for GoodJob operations
|
59
|
-
GoodJobEvent = T.type_alias {
|
60
|
-
T.any(
|
61
|
-
Event::Log, # General logging
|
62
|
-
Event::Enqueue, # Job queued
|
63
|
-
Event::Start, # Job execution started
|
64
|
-
Event::Finish, # Job completed successfully
|
65
|
-
Event::Error, # Job failed with error
|
66
|
-
Event::Schedule # Job scheduled for future execution
|
67
|
-
)
|
68
|
-
}
|
69
|
-
|
70
|
-
# Common fields
|
71
|
-
const :source, Source::Job, default: T.let(Source::Job, Source::Job)
|
72
|
-
const :event, GoodJobEvent
|
73
|
-
const :timestamp, Time, factory: -> { Time.now }
|
74
|
-
const :level, Level, default: T.let(Level::Info, Level)
|
75
|
-
|
76
|
-
# Job identification fields
|
77
|
-
const :job_id, T.nilable(String), default: nil
|
78
|
-
const :job_class, T.nilable(String), default: nil
|
79
|
-
const :queue_name, T.nilable(String), default: nil
|
80
|
-
const :batch_id, T.nilable(String), default: nil
|
81
|
-
const :job_label, T.nilable(String), default: nil
|
82
|
-
|
83
|
-
# Job execution context
|
84
|
-
const :arguments, T.nilable(T::Array[T.untyped]), default: nil
|
85
|
-
const :executions, T.nilable(Integer), default: nil
|
86
|
-
const :exception_executions, T.nilable(Integer), default: nil
|
87
|
-
const :execution_time, T.nilable(Float), default: nil
|
88
|
-
const :scheduled_at, T.nilable(Time), default: nil
|
89
|
-
|
90
|
-
# Error information
|
91
|
-
const :error_class, T.nilable(String), default: nil
|
92
|
-
const :error_message, T.nilable(String), default: nil
|
93
|
-
const :error_backtrace, T.nilable(T::Array[String]), default: nil
|
94
|
-
|
95
|
-
# GoodJob-specific metadata
|
96
|
-
const :process_id, T.nilable(Integer), default: nil
|
97
|
-
const :thread_id, T.nilable(String), default: nil
|
98
|
-
const :priority, T.nilable(Integer), default: nil
|
99
|
-
const :cron_key, T.nilable(String), default: nil
|
100
|
-
const :database_connection_name, T.nilable(String), default: nil
|
101
|
-
|
102
|
-
# Performance and metrics
|
103
|
-
const :wait_time, T.nilable(Float), default: nil
|
104
|
-
const :run_time, T.nilable(Float), default: nil
|
105
|
-
const :finished_at, T.nilable(Time), default: nil
|
106
|
-
|
107
|
-
# Additional contextual data
|
108
|
-
const :additional_data, T::Hash[Symbol, T.untyped], default: {}
|
109
|
-
|
110
|
-
# Convert the log entry to a hash for serialization
|
111
|
-
sig { override.params(strict: T::Boolean).returns(T::Hash[Symbol, T.untyped]) }
|
112
|
-
def serialize(strict = true)
|
113
|
-
hash = serialize_common(strict)
|
114
|
-
merge_additional_data_fields(hash)
|
115
|
-
|
116
|
-
# Add job identification fields
|
117
|
-
hash[LOG_KEYS.fetch(:job_id)] = job_id if job_id
|
118
|
-
hash[LOG_KEYS.fetch(:job_class)] = job_class if job_class
|
119
|
-
hash[LOG_KEYS.fetch(:queue_name)] = queue_name if queue_name
|
120
|
-
hash[:batch_id] = batch_id if batch_id
|
121
|
-
hash[:job_label] = job_label if job_label
|
122
|
-
|
123
|
-
# Add execution context
|
124
|
-
hash[LOG_KEYS.fetch(:arguments)] = arguments if arguments
|
125
|
-
hash[:executions] = executions if executions
|
126
|
-
hash[:exception_executions] = exception_executions if exception_executions
|
127
|
-
hash[:execution_time] = execution_time if execution_time
|
128
|
-
hash[:scheduled_at] = scheduled_at&.iso8601 if scheduled_at
|
129
|
-
|
130
|
-
# Add error information
|
131
|
-
hash[LOG_KEYS.fetch(:err_class)] = error_class if error_class
|
132
|
-
hash[:error_message] = error_message if error_message
|
133
|
-
hash[LOG_KEYS.fetch(:backtrace)] = error_backtrace if error_backtrace
|
134
|
-
|
135
|
-
# Add GoodJob-specific metadata
|
136
|
-
hash[LOG_KEYS.fetch(:process_id)] = process_id if process_id
|
137
|
-
hash[LOG_KEYS.fetch(:thread_id)] = thread_id if thread_id
|
138
|
-
hash[:priority] = priority if priority
|
139
|
-
hash[:cron_key] = cron_key if cron_key
|
140
|
-
hash[:database_connection_name] = database_connection_name if database_connection_name
|
141
|
-
|
142
|
-
# Add performance metrics
|
143
|
-
hash[:wait_time] = wait_time if wait_time
|
144
|
-
hash[:run_time] = run_time if run_time
|
145
|
-
hash[:finished_at] = finished_at&.iso8601 if finished_at
|
146
|
-
|
147
|
-
hash
|
18
|
+
class GoodJob
|
19
|
+
class BaseFields < T::Struct
|
20
|
+
extend T::Sig
|
21
|
+
const :job_id, T.nilable(String), default: nil
|
22
|
+
const :job_class, T.nilable(String), default: nil
|
23
|
+
const :queue_name, T.nilable(String), default: nil
|
24
|
+
const :arguments, T.nilable(T::Array[T.untyped]), default: nil
|
25
|
+
const :executions, T.nilable(Integer), default: nil
|
26
|
+
|
27
|
+
Kwargs = T.type_alias do
|
28
|
+
{
|
29
|
+
job_id: T.nilable(String),
|
30
|
+
job_class: T.nilable(String),
|
31
|
+
queue_name: T.nilable(String),
|
32
|
+
arguments: T.nilable(T::Array[T.untyped]),
|
33
|
+
executions: T.nilable(Integer)
|
34
|
+
}
|
35
|
+
end
|
36
|
+
|
37
|
+
sig { returns(Kwargs) }
|
38
|
+
def to_kwargs
|
39
|
+
{
|
40
|
+
job_id: job_id,
|
41
|
+
job_class: job_class,
|
42
|
+
queue_name: queue_name,
|
43
|
+
arguments: arguments,
|
44
|
+
executions: executions
|
45
|
+
}
|
46
|
+
end
|
148
47
|
end
|
149
48
|
end
|
150
49
|
end
|
@@ -1,20 +1,4 @@
|
|
1
1
|
# typed: strict
|
2
2
|
# frozen_string_literal: true
|
3
3
|
|
4
|
-
|
5
|
-
module Log
|
6
|
-
module Interfaces
|
7
|
-
# Common interface for logs that include an additional_data field
|
8
|
-
module AdditionalDataField
|
9
|
-
extend T::Sig
|
10
|
-
extend T::Helpers
|
11
|
-
|
12
|
-
interface!
|
13
|
-
|
14
|
-
# Additional data field for extra context
|
15
|
-
sig { abstract.returns(T::Hash[Symbol, T.untyped]) }
|
16
|
-
def additional_data; end
|
17
|
-
end
|
18
|
-
end
|
19
|
-
end
|
20
|
-
end
|
4
|
+
require "log_struct/shared/interfaces/additional_data_field"
|
@@ -1,42 +1,4 @@
|
|
1
1
|
# typed: strict
|
2
2
|
# frozen_string_literal: true
|
3
3
|
|
4
|
-
|
5
|
-
require_relative "../../enums/event"
|
6
|
-
require_relative "../../enums/level"
|
7
|
-
|
8
|
-
module LogStruct
|
9
|
-
module Log
|
10
|
-
module Interfaces
|
11
|
-
# Common interface that all log entry types must implement
|
12
|
-
module CommonFields
|
13
|
-
extend T::Sig
|
14
|
-
extend T::Helpers
|
15
|
-
|
16
|
-
interface!
|
17
|
-
|
18
|
-
# The source of the log entry (JSON property: src)
|
19
|
-
sig { abstract.returns(Source) }
|
20
|
-
def source; end
|
21
|
-
|
22
|
-
# The event type of the log entry (JSON property: evt)
|
23
|
-
sig { abstract.returns(Event) }
|
24
|
-
def event; end
|
25
|
-
|
26
|
-
# The log level (JSON property: lvl)
|
27
|
-
sig { abstract.returns(Level) }
|
28
|
-
def level; end
|
29
|
-
|
30
|
-
# The timestamp of the log entry (JSON property: ts)
|
31
|
-
sig { abstract.returns(Time) }
|
32
|
-
def timestamp; end
|
33
|
-
|
34
|
-
# All logs must define a custom serialize method
|
35
|
-
# If the class is a T::Struct that responds to serialize then we can be sure
|
36
|
-
# we're getting symbols as keys and don't need to call #serialize.deep_symbolize_keys
|
37
|
-
sig { abstract.params(strict: T::Boolean).returns(T::Hash[Symbol, T.untyped]) }
|
38
|
-
def serialize(strict = true); end
|
39
|
-
end
|
40
|
-
end
|
41
|
-
end
|
42
|
-
end
|
4
|
+
require "log_struct/shared/interfaces/common_fields"
|
@@ -1,31 +1,4 @@
|
|
1
1
|
# typed: strict
|
2
2
|
# frozen_string_literal: true
|
3
3
|
|
4
|
-
|
5
|
-
|
6
|
-
module LogStruct
|
7
|
-
module Log
|
8
|
-
module Interfaces
|
9
|
-
# Public interface for custom app log types.
|
10
|
-
# Allows String/Symbol for source and event so apps can define their own domains.
|
11
|
-
module PublicCommonFields
|
12
|
-
extend T::Sig
|
13
|
-
extend T::Helpers
|
14
|
-
|
15
|
-
interface!
|
16
|
-
|
17
|
-
# Log level (defaults to Info in most structs)
|
18
|
-
sig { abstract.returns(Level) }
|
19
|
-
def level; end
|
20
|
-
|
21
|
-
# Timestamp for the entry
|
22
|
-
sig { abstract.returns(Time) }
|
23
|
-
def timestamp; end
|
24
|
-
|
25
|
-
# Custom serialize method returning symbol-keyed hash
|
26
|
-
sig { abstract.params(strict: T::Boolean).returns(T::Hash[Symbol, T.untyped]) }
|
27
|
-
def serialize(strict = true); end
|
28
|
-
end
|
29
|
-
end
|
30
|
-
end
|
31
|
-
end
|
4
|
+
require "log_struct/shared/interfaces/public_common_fields"
|
@@ -1,36 +1,4 @@
|
|
1
1
|
# typed: strict
|
2
2
|
# frozen_string_literal: true
|
3
3
|
|
4
|
-
|
5
|
-
module Log
|
6
|
-
module Interfaces
|
7
|
-
# Common interface for request-related fields
|
8
|
-
# Used by both Request and Security logs
|
9
|
-
module RequestFields
|
10
|
-
extend T::Sig
|
11
|
-
extend T::Helpers
|
12
|
-
|
13
|
-
interface!
|
14
|
-
|
15
|
-
# Common request fields
|
16
|
-
sig { abstract.returns(T.nilable(String)) }
|
17
|
-
def path; end
|
18
|
-
|
19
|
-
sig { abstract.returns(T.nilable(String)) }
|
20
|
-
def http_method; end
|
21
|
-
|
22
|
-
sig { abstract.returns(T.nilable(String)) }
|
23
|
-
def source_ip; end
|
24
|
-
|
25
|
-
sig { abstract.returns(T.nilable(String)) }
|
26
|
-
def user_agent; end
|
27
|
-
|
28
|
-
sig { abstract.returns(T.nilable(String)) }
|
29
|
-
def referer; end
|
30
|
-
|
31
|
-
sig { abstract.returns(T.nilable(String)) }
|
32
|
-
def request_id; end
|
33
|
-
end
|
34
|
-
end
|
35
|
-
end
|
36
|
-
end
|
4
|
+
require "log_struct/shared/interfaces/request_fields"
|
data/lib/log_struct/log/plain.rb
CHANGED
@@ -1,52 +1,77 @@
|
|
1
1
|
# typed: strict
|
2
2
|
# frozen_string_literal: true
|
3
3
|
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
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"
|
8
15
|
require_relative "../enums/source"
|
9
16
|
require_relative "../enums/event"
|
10
17
|
require_relative "../enums/level"
|
11
|
-
require_relative "../
|
18
|
+
require_relative "../enums/log_field"
|
12
19
|
|
13
20
|
module LogStruct
|
14
21
|
module Log
|
15
|
-
# Plain log entry for structured logging
|
16
22
|
class Plain < T::Struct
|
17
|
-
|
23
|
+
# typed: strict
|
24
|
+
# frozen_string_literal: true
|
18
25
|
|
19
|
-
|
20
|
-
include Interfaces::AdditionalDataField
|
21
|
-
include SerializeCommon
|
22
|
-
include MergeAdditionalDataFields
|
26
|
+
extend T::Sig
|
23
27
|
|
24
|
-
|
25
|
-
Event::Log
|
26
|
-
}
|
28
|
+
extend T::Sig
|
27
29
|
|
28
|
-
#
|
29
|
-
const :source, Source, default:
|
30
|
-
const :event,
|
31
|
-
const :level, Level, default: T.let(Level::Info, Level)
|
30
|
+
# Shared/common fields
|
31
|
+
const :source, Source::App, default: Source::App
|
32
|
+
const :event, Event, default: Event::Log
|
32
33
|
const :timestamp, Time, factory: -> { Time.now }
|
34
|
+
const :level, Level, default: Level::Info
|
35
|
+
|
36
|
+
# Event-specific fields
|
37
|
+
const :message, T.untyped
|
38
|
+
|
39
|
+
# Additional data
|
40
|
+
include LogStruct::Log::Interfaces::AdditionalDataField
|
41
|
+
const :additional_data, T.nilable(T::Hash[T.any(String, Symbol), T.untyped]), default: nil
|
42
|
+
include LogStruct::Log::Shared::MergeAdditionalDataFields
|
43
|
+
|
44
|
+
# Request fields (optional)
|
45
|
+
|
46
|
+
# Serialize shared fields
|
47
|
+
include LogStruct::Log::Interfaces::CommonFields
|
48
|
+
include LogStruct::Log::Shared::SerializeCommon
|
49
|
+
|
50
|
+
sig { returns(T::Hash[LogStruct::LogField, T.untyped]) }
|
51
|
+
def self.base_hash
|
52
|
+
{}
|
53
|
+
end
|
54
|
+
|
55
|
+
sig {
|
56
|
+
params(message: T.untyped,
|
57
|
+
additional_data: T.untyped,
|
58
|
+
timestamp: T.untyped).returns(T::Hash[LogStruct::LogField, T.untyped])
|
59
|
+
}
|
60
|
+
def self.build(message:,
|
61
|
+
additional_data: nil,
|
62
|
+
timestamp: Time.now)
|
63
|
+
h = base_hash
|
64
|
+
h[LogField::Message] = message
|
65
|
+
h
|
66
|
+
end
|
33
67
|
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
const :additional_data, T::Hash[Symbol, T.untyped], default: {}
|
42
|
-
|
43
|
-
# Convert the log entry to a hash for serialization
|
44
|
-
sig { override.params(strict: T::Boolean).returns(T::Hash[Symbol, T.untyped]) }
|
45
|
-
def serialize(strict = true)
|
46
|
-
hash = serialize_common(strict)
|
47
|
-
merge_additional_data_fields(hash)
|
48
|
-
hash[LOG_KEYS.fetch(:message)] = message
|
49
|
-
hash
|
68
|
+
sig { returns(T::Hash[LogStruct::LogField, T.untyped]) }
|
69
|
+
def to_h
|
70
|
+
self.class.build(
|
71
|
+
message: message,
|
72
|
+
additional_data: additional_data,
|
73
|
+
timestamp: timestamp
|
74
|
+
)
|
50
75
|
end
|
51
76
|
end
|
52
77
|
end
|
@@ -0,0 +1,80 @@
|
|
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 Puma
|
23
|
+
class Shutdown < 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::Puma, default: Source::Puma
|
33
|
+
const :event, Event, default: Event::Shutdown
|
34
|
+
const :timestamp, Time, factory: -> { Time.now }
|
35
|
+
const :level, Level, default: Level::Info
|
36
|
+
|
37
|
+
# Event-specific fields
|
38
|
+
const :process_id, T.nilable(Integer), default: nil
|
39
|
+
|
40
|
+
# Additional data
|
41
|
+
include LogStruct::Log::Interfaces::AdditionalDataField
|
42
|
+
const :additional_data, T.nilable(T::Hash[T.any(String, Symbol), T.untyped]), default: nil
|
43
|
+
include LogStruct::Log::Shared::MergeAdditionalDataFields
|
44
|
+
|
45
|
+
# Request fields (optional)
|
46
|
+
|
47
|
+
# Serialize shared fields
|
48
|
+
include LogStruct::Log::Interfaces::CommonFields
|
49
|
+
include LogStruct::Log::Shared::SerializeCommon
|
50
|
+
|
51
|
+
sig { returns(T::Hash[LogStruct::LogField, T.untyped]) }
|
52
|
+
def self.base_hash
|
53
|
+
{}
|
54
|
+
end
|
55
|
+
|
56
|
+
sig {
|
57
|
+
params(process_id: T.untyped,
|
58
|
+
additional_data: T.untyped,
|
59
|
+
timestamp: T.untyped).returns(T::Hash[LogStruct::LogField, T.untyped])
|
60
|
+
}
|
61
|
+
def self.build(process_id: nil,
|
62
|
+
additional_data: nil,
|
63
|
+
timestamp: Time.now)
|
64
|
+
h = base_hash
|
65
|
+
h[LogField::ProcessId] = process_id unless process_id.nil?
|
66
|
+
h
|
67
|
+
end
|
68
|
+
|
69
|
+
sig { returns(T::Hash[LogStruct::LogField, T.untyped]) }
|
70
|
+
def to_h
|
71
|
+
self.class.build(
|
72
|
+
process_id: process_id,
|
73
|
+
additional_data: additional_data,
|
74
|
+
timestamp: timestamp
|
75
|
+
)
|
76
|
+
end
|
77
|
+
end
|
78
|
+
end
|
79
|
+
end
|
80
|
+
end
|
@@ -0,0 +1,120 @@
|
|
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 Puma
|
23
|
+
class Start < 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::Puma, default: Source::Puma
|
33
|
+
const :event, Event, default: Event::Start
|
34
|
+
const :timestamp, Time, factory: -> { Time.now }
|
35
|
+
const :level, Level, default: Level::Info
|
36
|
+
|
37
|
+
# Event-specific fields
|
38
|
+
const :mode, T.nilable(String), default: nil
|
39
|
+
const :puma_version, T.nilable(String), default: nil
|
40
|
+
const :puma_codename, T.nilable(String), default: nil
|
41
|
+
const :ruby_version, T.nilable(String), default: nil
|
42
|
+
const :min_threads, T.nilable(Integer), default: nil
|
43
|
+
const :max_threads, T.nilable(Integer), default: nil
|
44
|
+
const :environment, T.nilable(String), default: nil
|
45
|
+
const :process_id, T.nilable(Integer), default: nil
|
46
|
+
const :listening_addresses, T.nilable(T::Array[String]), default: nil
|
47
|
+
|
48
|
+
# Additional data
|
49
|
+
include LogStruct::Log::Interfaces::AdditionalDataField
|
50
|
+
const :additional_data, T.nilable(T::Hash[T.any(String, Symbol), T.untyped]), default: nil
|
51
|
+
include LogStruct::Log::Shared::MergeAdditionalDataFields
|
52
|
+
|
53
|
+
# Request fields (optional)
|
54
|
+
|
55
|
+
# Serialize shared fields
|
56
|
+
include LogStruct::Log::Interfaces::CommonFields
|
57
|
+
include LogStruct::Log::Shared::SerializeCommon
|
58
|
+
|
59
|
+
sig { returns(T::Hash[LogStruct::LogField, T.untyped]) }
|
60
|
+
def self.base_hash
|
61
|
+
{}
|
62
|
+
end
|
63
|
+
|
64
|
+
sig {
|
65
|
+
params(mode: T.untyped,
|
66
|
+
puma_version: T.untyped,
|
67
|
+
puma_codename: T.untyped,
|
68
|
+
ruby_version: T.untyped,
|
69
|
+
min_threads: T.untyped,
|
70
|
+
max_threads: T.untyped,
|
71
|
+
environment: T.untyped,
|
72
|
+
process_id: T.untyped,
|
73
|
+
listening_addresses: T.untyped,
|
74
|
+
additional_data: T.untyped,
|
75
|
+
timestamp: T.untyped).returns(T::Hash[LogStruct::LogField, T.untyped])
|
76
|
+
}
|
77
|
+
def self.build(mode: nil,
|
78
|
+
puma_version: nil,
|
79
|
+
puma_codename: nil,
|
80
|
+
ruby_version: nil,
|
81
|
+
min_threads: nil,
|
82
|
+
max_threads: nil,
|
83
|
+
environment: nil,
|
84
|
+
process_id: nil,
|
85
|
+
listening_addresses: nil,
|
86
|
+
additional_data: nil,
|
87
|
+
timestamp: Time.now)
|
88
|
+
h = base_hash
|
89
|
+
h[LogField::Mode] = mode unless mode.nil?
|
90
|
+
h[LogField::PumaVersion] = puma_version unless puma_version.nil?
|
91
|
+
h[LogField::PumaCodename] = puma_codename unless puma_codename.nil?
|
92
|
+
h[LogField::RubyVersion] = ruby_version unless ruby_version.nil?
|
93
|
+
h[LogField::MinThreads] = min_threads unless min_threads.nil?
|
94
|
+
h[LogField::MaxThreads] = max_threads unless max_threads.nil?
|
95
|
+
h[LogField::Environment] = environment unless environment.nil?
|
96
|
+
h[LogField::ProcessId] = process_id unless process_id.nil?
|
97
|
+
h[LogField::ListeningAddresses] = listening_addresses unless listening_addresses.nil?
|
98
|
+
h
|
99
|
+
end
|
100
|
+
|
101
|
+
sig { returns(T::Hash[LogStruct::LogField, T.untyped]) }
|
102
|
+
def to_h
|
103
|
+
self.class.build(
|
104
|
+
mode: mode,
|
105
|
+
puma_version: puma_version,
|
106
|
+
puma_codename: puma_codename,
|
107
|
+
ruby_version: ruby_version,
|
108
|
+
min_threads: min_threads,
|
109
|
+
max_threads: max_threads,
|
110
|
+
environment: environment,
|
111
|
+
process_id: process_id,
|
112
|
+
listening_addresses: listening_addresses,
|
113
|
+
additional_data: additional_data,
|
114
|
+
timestamp: timestamp
|
115
|
+
)
|
116
|
+
end
|
117
|
+
end
|
118
|
+
end
|
119
|
+
end
|
120
|
+
end
|
@@ -0,0 +1,10 @@
|
|
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/source_parent.rb.erb
|
8
|
+
|
9
|
+
require_relative "puma/start"
|
10
|
+
require_relative "puma/shutdown"
|