logstruct 0.0.2 → 0.1.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.
- checksums.yaml +4 -4
- data/CHANGELOG.md +2 -24
- data/README.md +10 -0
- data/lib/log_struct/concerns/logging.rb +5 -5
- data/lib/log_struct/config_struct/integrations.rb +8 -0
- data/lib/log_struct/integrations/active_model_serializers.rb +55 -0
- data/lib/log_struct/integrations/ahoy.rb +53 -0
- data/lib/log_struct/integrations.rb +4 -0
- data/lib/log_struct/log/active_model_serializers.rb +55 -0
- data/lib/log_struct/log/ahoy.rb +54 -0
- data/lib/log_struct/log/error.rb +1 -0
- data/lib/log_struct/log/interfaces/public_common_fields.rb +31 -0
- data/lib/log_struct/log/shared/merge_additional_data_fields.rb +0 -3
- data/lib/log_struct/log/shared/serialize_common_public.rb +44 -0
- data/lib/log_struct/log.rb +7 -1
- data/lib/log_struct/version.rb +1 -1
- data/logstruct.gemspec +2 -0
- metadata +36 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2a68693a793bd472926424e34f602e5f81a677e0bac2b0b8da189e7bc5adb10a
|
4
|
+
data.tar.gz: 8d5dd33db82a1b4eda1b8f1b0631af0cb3b04eba1e9d034e275192a49d8b9285
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2c8afb5d952a2ec1ead718b5655cd6af260978cd001502cd2dde3f8fb66e15720a5fca9f1646b8e132cad03ab48c51507b6a5d9948080019ca17ec4011b3b347
|
7
|
+
data.tar.gz: af94c2f9805ec7f121df828e25b1214395450acec0ed475a5b98ca26bef564c537c2bb522f3494152fb2df5d9b0b4850d7c158a3df794fad635a60613796fd51
|
data/CHANGELOG.md
CHANGED
@@ -5,28 +5,6 @@ All notable changes to this project will be documented in this file.
|
|
5
5
|
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
6
6
|
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
7
7
|
|
8
|
-
## [0.0
|
8
|
+
## [0.1.0] - 2025-09-07
|
9
9
|
|
10
|
-
|
11
|
-
|
12
|
-
- Pushed empty gem to RubyGems to secure the name
|
13
|
-
|
14
|
-
## [0.0.2-rc1] - 2025-09-05
|
15
|
-
|
16
|
-
### Added
|
17
|
-
|
18
|
-
- Unified GitHub Actions workflow to release RubyGem and sync/tag the Terraform provider; dry-run support for safe validation
|
19
|
-
- Provider catalog export script and automated provider CI (build/vet/test)
|
20
|
-
- Terraform docs page with quickstart, recipes, and provider README link
|
21
|
-
- API design doc (typed vs. untyped) planned; initial philosophy captured
|
22
|
-
- Coverage threshold gate (>= 80%) in CI; additional tests to lift coverage
|
23
|
-
- Release helper: scripts/create_release_tag.sh (creates annotated tag from version.rb)
|
24
|
-
|
25
|
-
### Changed
|
26
|
-
|
27
|
-
- ActionMailer callbacks patched for Rails 7.0; event logging + metadata collection tested
|
28
|
-
- Provider CloudWatch filter builder refactored for testability; key lookups aligned with exported catalog (event/source)
|
29
|
-
|
30
|
-
### Fixed
|
31
|
-
|
32
|
-
- Pre-commit hooks reporting; cspell dictionary updated; TypeScript import fixes in site
|
10
|
+
Initial release.
|
data/README.md
CHANGED
@@ -62,6 +62,16 @@ Once initialized, the gem automatically includes its modules into the appropriat
|
|
62
62
|
|
63
63
|
Please see the [documentation](https://logstruct.com/docs) for more details. (All code examples are type-checked and tested, and it's harder to keep a README up to date.)
|
64
64
|
|
65
|
+
### Custom Typed Logs
|
66
|
+
|
67
|
+
In addition to the built‑in, strictly typed log structures (Request, Error, SQL, etc.), you can define your own app‑specific typed logs while still using the public `LogStruct.info/error/...` methods.
|
68
|
+
|
69
|
+
- Compose the public interfaces: include `LogStruct::Log::Interfaces::PublicCommonFields` and the helpers `SerializeCommonPublic` + `MergeAdditionalDataFields` in your `T::Struct`.
|
70
|
+
- Fix your `source` to a constant (e.g., return the string `"payments"`), and restrict `event` with a `T::Enum` (e.g., `processed|failed|refunded`).
|
71
|
+
- The `LogStruct.info` signature accepts either the internal `CommonFields` (for built‑ins) or your public custom type, so you keep type safety at the call site.
|
72
|
+
|
73
|
+
See the docs page for a complete example: [Sorbet Types → Custom Typed Logs](https://logstruct.com/docs/sorbet-types#custom-log-classes).
|
74
|
+
|
65
75
|
## License
|
66
76
|
|
67
77
|
This project is licensed under the MIT License. See the [LICENSE](LICENSE) file for details.
|
@@ -11,31 +11,31 @@ module LogStruct
|
|
11
11
|
extend T::Sig
|
12
12
|
|
13
13
|
# Log a log struct at debug level
|
14
|
-
sig { params(log: Log::Interfaces::CommonFields).void }
|
14
|
+
sig { params(log: T.any(Log::Interfaces::CommonFields, Log::Interfaces::PublicCommonFields)).void }
|
15
15
|
def debug(log)
|
16
16
|
Rails.logger.debug(log)
|
17
17
|
end
|
18
18
|
|
19
19
|
# Log a log struct at info level
|
20
|
-
sig { params(log: Log::Interfaces::CommonFields).void }
|
20
|
+
sig { params(log: T.any(Log::Interfaces::CommonFields, Log::Interfaces::PublicCommonFields)).void }
|
21
21
|
def info(log)
|
22
22
|
Rails.logger.info(log)
|
23
23
|
end
|
24
24
|
|
25
25
|
# Log a log struct at warn level
|
26
|
-
sig { params(log: Log::Interfaces::CommonFields).void }
|
26
|
+
sig { params(log: T.any(Log::Interfaces::CommonFields, Log::Interfaces::PublicCommonFields)).void }
|
27
27
|
def warn(log)
|
28
28
|
Rails.logger.warn(log)
|
29
29
|
end
|
30
30
|
|
31
31
|
# Log a log struct at error level
|
32
|
-
sig { params(log: Log::Interfaces::CommonFields).void }
|
32
|
+
sig { params(log: T.any(Log::Interfaces::CommonFields, Log::Interfaces::PublicCommonFields)).void }
|
33
33
|
def error(log)
|
34
34
|
Rails.logger.error(log)
|
35
35
|
end
|
36
36
|
|
37
37
|
# Log a log struct at fatal level
|
38
|
-
sig { params(log: Log::Interfaces::CommonFields).void }
|
38
|
+
sig { params(log: T.any(Log::Interfaces::CommonFields, Log::Interfaces::PublicCommonFields)).void }
|
39
39
|
def fatal(log)
|
40
40
|
Rails.logger.fatal(log)
|
41
41
|
end
|
@@ -84,6 +84,14 @@ module LogStruct
|
|
84
84
|
# Include bind parameters in SQL logs (disable in production for security)
|
85
85
|
# Default: true in development/test, false in production
|
86
86
|
prop :sql_log_bind_params, T::Boolean, factory: -> { !defined?(::Rails) || !::Rails.respond_to?(:env) || !::Rails.env.production? }
|
87
|
+
|
88
|
+
# Enable Ahoy (analytics events) integration
|
89
|
+
# Default: true (safe no-op unless Ahoy is defined)
|
90
|
+
prop :enable_ahoy, T::Boolean, default: true
|
91
|
+
|
92
|
+
# Enable ActiveModelSerializers integration
|
93
|
+
# Default: true (safe no-op unless ActiveModelSerializers is defined)
|
94
|
+
prop :enable_active_model_serializers, T::Boolean, default: true
|
87
95
|
end
|
88
96
|
end
|
89
97
|
end
|
@@ -0,0 +1,55 @@
|
|
1
|
+
# typed: strict
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
4
|
+
require "active_support/notifications"
|
5
|
+
|
6
|
+
module LogStruct
|
7
|
+
module Integrations
|
8
|
+
# ActiveModelSerializers integration. Subscribes to AMS notifications and
|
9
|
+
# emits structured logs with serializer/adapter/duration details.
|
10
|
+
module ActiveModelSerializers
|
11
|
+
extend T::Sig
|
12
|
+
|
13
|
+
sig { params(config: LogStruct::Configuration).returns(T.nilable(TrueClass)) }
|
14
|
+
def self.setup(config)
|
15
|
+
return nil unless defined?(::ActiveSupport::Notifications)
|
16
|
+
|
17
|
+
# Only activate if AMS appears to be present
|
18
|
+
return nil unless defined?(::ActiveModelSerializers)
|
19
|
+
|
20
|
+
# Subscribe to common AMS notification names; keep broad but specific
|
21
|
+
pattern = /\.active_model_serializers\z/
|
22
|
+
|
23
|
+
::ActiveSupport::Notifications.subscribe(pattern) do |_name, started, finished, _unique_id, payload|
|
24
|
+
duration_ms = ((finished - started) * 1000.0)
|
25
|
+
|
26
|
+
data = {
|
27
|
+
duration_ms: duration_ms
|
28
|
+
}
|
29
|
+
|
30
|
+
serializer = payload[:serializer] || payload[:serializer_class]
|
31
|
+
adapter = payload[:adapter]
|
32
|
+
resource = payload[:resource] || payload[:object]
|
33
|
+
|
34
|
+
data[:serializer] = serializer.to_s if serializer
|
35
|
+
data[:adapter] = adapter.to_s if adapter
|
36
|
+
data[:resource_class] = resource.class.name if resource
|
37
|
+
|
38
|
+
LogStruct.info(
|
39
|
+
LogStruct::Log::ActiveModelSerializers.new(
|
40
|
+
serializer: data[:serializer]&.to_s,
|
41
|
+
adapter: data[:adapter]&.to_s,
|
42
|
+
resource_class: data[:resource_class]&.to_s,
|
43
|
+
duration_ms: T.cast(data[:duration_ms], T.nilable(Float)),
|
44
|
+
additional_data: {}
|
45
|
+
)
|
46
|
+
)
|
47
|
+
rescue => e
|
48
|
+
LogStruct.handle_exception(e, source: LogStruct::Source::Rails, context: {integration: :active_model_serializers})
|
49
|
+
end
|
50
|
+
|
51
|
+
true
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
@@ -0,0 +1,53 @@
|
|
1
|
+
# typed: strict
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
4
|
+
module LogStruct
|
5
|
+
module Integrations
|
6
|
+
# Ahoy analytics integration. If Ahoy is present, prepend a small hook to
|
7
|
+
# Ahoy::Tracker#track to emit a structured log for analytics events.
|
8
|
+
module Ahoy
|
9
|
+
extend T::Sig
|
10
|
+
|
11
|
+
sig { params(config: LogStruct::Configuration).returns(T.nilable(TrueClass)) }
|
12
|
+
def self.setup(config)
|
13
|
+
return nil unless defined?(::Ahoy)
|
14
|
+
|
15
|
+
if defined?(::Ahoy::Tracker)
|
16
|
+
mod = Module.new do
|
17
|
+
extend T::Sig
|
18
|
+
|
19
|
+
sig { params(name: T.untyped, properties: T.nilable(T::Hash[T.untyped, T.untyped]), options: T.untyped).returns(T.untyped) }
|
20
|
+
def track(name, properties = nil, options = nil)
|
21
|
+
result = super
|
22
|
+
begin
|
23
|
+
# Emit a lightweight structured log about the analytics event
|
24
|
+
data = {
|
25
|
+
ahoy_event: T.let(name, T.untyped)
|
26
|
+
}
|
27
|
+
data[:properties] = properties if properties
|
28
|
+
LogStruct.info(
|
29
|
+
LogStruct::Log::Ahoy.new(
|
30
|
+
ahoy_event: T.let(name, T.nilable(String)),
|
31
|
+
properties: T.let(
|
32
|
+
properties && properties.transform_keys { |k| k.to_sym },
|
33
|
+
T.nilable(T::Hash[Symbol, T.untyped])
|
34
|
+
),
|
35
|
+
additional_data: {}
|
36
|
+
)
|
37
|
+
)
|
38
|
+
rescue => e
|
39
|
+
# Never raise from logging; rely on global error handling policies
|
40
|
+
LogStruct.handle_exception(e, source: LogStruct::Source::App, context: {integration: :ahoy})
|
41
|
+
end
|
42
|
+
result
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
T.unsafe(::Ahoy::Tracker).prepend(mod)
|
47
|
+
end
|
48
|
+
|
49
|
+
true
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
@@ -14,6 +14,8 @@ require_relative "integrations/good_job"
|
|
14
14
|
require_relative "integrations/active_storage"
|
15
15
|
require_relative "integrations/carrierwave"
|
16
16
|
require_relative "integrations/sorbet"
|
17
|
+
require_relative "integrations/ahoy"
|
18
|
+
require_relative "integrations/active_model_serializers"
|
17
19
|
|
18
20
|
module LogStruct
|
19
21
|
module Integrations
|
@@ -30,6 +32,8 @@ module LogStruct
|
|
30
32
|
Integrations::ActiveRecord.setup(config) if config.integrations.enable_sql_logging
|
31
33
|
Integrations::Sidekiq.setup(config) if config.integrations.enable_sidekiq
|
32
34
|
Integrations::GoodJob.setup(config) if config.integrations.enable_goodjob
|
35
|
+
Integrations::Ahoy.setup(config) if config.integrations.enable_ahoy
|
36
|
+
Integrations::ActiveModelSerializers.setup(config) if config.integrations.enable_active_model_serializers
|
33
37
|
Integrations::HostAuthorization.setup(config) if config.integrations.enable_host_authorization
|
34
38
|
Integrations::RackErrorHandler.setup(config) if config.integrations.enable_rack_error_handler
|
35
39
|
Integrations::Shrine.setup(config) if config.integrations.enable_shrine
|
@@ -0,0 +1,55 @@
|
|
1
|
+
# typed: strict
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
4
|
+
require_relative "interfaces/common_fields"
|
5
|
+
require_relative "interfaces/additional_data_field"
|
6
|
+
require_relative "shared/serialize_common"
|
7
|
+
require_relative "shared/merge_additional_data_fields"
|
8
|
+
require_relative "../enums/source"
|
9
|
+
require_relative "../enums/event"
|
10
|
+
require_relative "../enums/level"
|
11
|
+
require_relative "../log_keys"
|
12
|
+
|
13
|
+
module LogStruct
|
14
|
+
module Log
|
15
|
+
# ActiveModelSerializers render log entry for structured logging
|
16
|
+
class ActiveModelSerializers < T::Struct
|
17
|
+
extend T::Sig
|
18
|
+
|
19
|
+
include Interfaces::CommonFields
|
20
|
+
include Interfaces::AdditionalDataField
|
21
|
+
include SerializeCommon
|
22
|
+
include MergeAdditionalDataFields
|
23
|
+
|
24
|
+
AMSEvent = T.type_alias { Event::Log }
|
25
|
+
|
26
|
+
# Common fields
|
27
|
+
const :source, Source::Rails, default: T.let(Source::Rails, Source::Rails)
|
28
|
+
const :event, AMSEvent, default: T.let(Event::Log, AMSEvent)
|
29
|
+
const :level, Level, default: T.let(Level::Info, Level)
|
30
|
+
const :timestamp, Time, factory: -> { Time.now }
|
31
|
+
|
32
|
+
# AMS specifics
|
33
|
+
const :message, String, default: "ams.render"
|
34
|
+
const :serializer, T.nilable(String), default: nil
|
35
|
+
const :adapter, T.nilable(String), default: nil
|
36
|
+
const :resource_class, T.nilable(String), default: nil
|
37
|
+
const :duration_ms, T.nilable(Float), default: nil
|
38
|
+
|
39
|
+
# Extra data
|
40
|
+
const :additional_data, T::Hash[Symbol, T.untyped], default: {}
|
41
|
+
|
42
|
+
sig { override.params(strict: T::Boolean).returns(T::Hash[Symbol, T.untyped]) }
|
43
|
+
def serialize(strict = true)
|
44
|
+
hash = serialize_common(strict)
|
45
|
+
merge_additional_data_fields(hash)
|
46
|
+
hash[LOG_KEYS.fetch(:message)] = message
|
47
|
+
hash[:serializer] = serializer if serializer
|
48
|
+
hash[:adapter] = adapter if adapter
|
49
|
+
hash[:resource_class] = resource_class if resource_class
|
50
|
+
hash[:duration_ms] = duration_ms if duration_ms
|
51
|
+
hash
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
@@ -0,0 +1,54 @@
|
|
1
|
+
# typed: strict
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
4
|
+
require_relative "interfaces/common_fields"
|
5
|
+
require_relative "interfaces/additional_data_field"
|
6
|
+
require_relative "shared/serialize_common"
|
7
|
+
require_relative "shared/merge_additional_data_fields"
|
8
|
+
require_relative "../enums/source"
|
9
|
+
require_relative "../enums/event"
|
10
|
+
require_relative "../enums/level"
|
11
|
+
require_relative "../log_keys"
|
12
|
+
|
13
|
+
module LogStruct
|
14
|
+
module Log
|
15
|
+
# Ahoy analytics log entry for structured logging
|
16
|
+
class Ahoy < T::Struct
|
17
|
+
extend T::Sig
|
18
|
+
|
19
|
+
include Interfaces::CommonFields
|
20
|
+
include Interfaces::AdditionalDataField
|
21
|
+
include SerializeCommon
|
22
|
+
include MergeAdditionalDataFields
|
23
|
+
|
24
|
+
# Events are generic logs for tracking
|
25
|
+
AhoyEvent = T.type_alias {
|
26
|
+
Event::Log
|
27
|
+
}
|
28
|
+
|
29
|
+
# Common fields
|
30
|
+
const :source, Source, default: T.let(Source::App, Source)
|
31
|
+
const :event, AhoyEvent, default: T.let(Event::Log, AhoyEvent)
|
32
|
+
const :level, Level, default: T.let(Level::Info, Level)
|
33
|
+
const :timestamp, Time, factory: -> { Time.now }
|
34
|
+
|
35
|
+
# Ahoy specifics
|
36
|
+
const :message, String, default: "ahoy.track"
|
37
|
+
const :ahoy_event, T.nilable(String), default: nil
|
38
|
+
const :properties, T.nilable(T::Hash[Symbol, T.untyped]), default: nil
|
39
|
+
|
40
|
+
# Extra data
|
41
|
+
const :additional_data, T::Hash[Symbol, T.untyped], default: {}
|
42
|
+
|
43
|
+
sig { override.params(strict: T::Boolean).returns(T::Hash[Symbol, T.untyped]) }
|
44
|
+
def serialize(strict = true)
|
45
|
+
hash = serialize_common(strict)
|
46
|
+
merge_additional_data_fields(hash)
|
47
|
+
hash[LOG_KEYS.fetch(:message)] = message
|
48
|
+
hash[:ahoy_event] = ahoy_event if ahoy_event
|
49
|
+
hash[:properties] = properties if properties
|
50
|
+
hash
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
data/lib/log_struct/log/error.rb
CHANGED
@@ -0,0 +1,31 @@
|
|
1
|
+
# typed: strict
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
4
|
+
require_relative "../../enums/level"
|
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
|
@@ -3,7 +3,6 @@
|
|
3
3
|
|
4
4
|
require_relative "../../log_keys"
|
5
5
|
require_relative "../interfaces/additional_data_field"
|
6
|
-
require_relative "serialize_common"
|
7
6
|
|
8
7
|
module LogStruct
|
9
8
|
module Log
|
@@ -12,8 +11,6 @@ module LogStruct
|
|
12
11
|
extend T::Sig
|
13
12
|
extend T::Helpers
|
14
13
|
|
15
|
-
include SerializeCommon
|
16
|
-
|
17
14
|
requires_ancestor { T::Struct }
|
18
15
|
requires_ancestor { Interfaces::AdditionalDataField }
|
19
16
|
|
@@ -0,0 +1,44 @@
|
|
1
|
+
# typed: strict
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
4
|
+
require_relative "../../log_keys"
|
5
|
+
require_relative "../interfaces/public_common_fields"
|
6
|
+
|
7
|
+
module LogStruct
|
8
|
+
module Log
|
9
|
+
# Common serialization for public custom log structs with string/symbol source/event
|
10
|
+
module SerializeCommonPublic
|
11
|
+
extend T::Sig
|
12
|
+
extend T::Helpers
|
13
|
+
|
14
|
+
requires_ancestor { Interfaces::PublicCommonFields }
|
15
|
+
requires_ancestor { Kernel }
|
16
|
+
|
17
|
+
sig { params(strict: T::Boolean).returns(T::Hash[Symbol, T.untyped]) }
|
18
|
+
def serialize_common_public(strict = true)
|
19
|
+
unless respond_to?(:source) && respond_to?(:event)
|
20
|
+
raise ArgumentError, "Public log struct must define #source and #event"
|
21
|
+
end
|
22
|
+
|
23
|
+
src_val = T.unsafe(self).source
|
24
|
+
evt_val = T.unsafe(self).event
|
25
|
+
src = src_val.respond_to?(:serialize) ? T.unsafe(src_val).serialize.to_s : src_val.to_s
|
26
|
+
evt = evt_val.respond_to?(:serialize) ? T.unsafe(evt_val).serialize.to_s : evt_val.to_s
|
27
|
+
lvl = level.serialize.to_s
|
28
|
+
ts = timestamp.iso8601(3)
|
29
|
+
|
30
|
+
{
|
31
|
+
LOG_KEYS.fetch(:source) => src,
|
32
|
+
LOG_KEYS.fetch(:event) => evt,
|
33
|
+
LOG_KEYS.fetch(:level) => lvl,
|
34
|
+
LOG_KEYS.fetch(:timestamp) => ts
|
35
|
+
}
|
36
|
+
end
|
37
|
+
|
38
|
+
sig { params(options: T.untyped).returns(T::Hash[String, T.untyped]) }
|
39
|
+
def as_json(options = nil)
|
40
|
+
serialize.transform_keys(&:to_s)
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
data/lib/log_struct/log.rb
CHANGED
@@ -5,6 +5,8 @@
|
|
5
5
|
require_relative "enums/source"
|
6
6
|
require_relative "enums/event"
|
7
7
|
require_relative "enums/level"
|
8
|
+
require_relative "log/interfaces/public_common_fields"
|
9
|
+
require_relative "log/shared/serialize_common_public"
|
8
10
|
|
9
11
|
# Log Structs
|
10
12
|
require_relative "log/carrierwave"
|
@@ -19,6 +21,8 @@ require_relative "log/security"
|
|
19
21
|
require_relative "log/shrine"
|
20
22
|
require_relative "log/sidekiq"
|
21
23
|
require_relative "log/sql"
|
24
|
+
require_relative "log/ahoy"
|
25
|
+
require_relative "log/active_model_serializers"
|
22
26
|
|
23
27
|
module LogStruct
|
24
28
|
# Type aliases for all possible log types
|
@@ -37,7 +41,9 @@ module LogStruct
|
|
37
41
|
T.class_of(LogStruct::Log::Security),
|
38
42
|
T.class_of(LogStruct::Log::Shrine),
|
39
43
|
T.class_of(LogStruct::Log::Sidekiq),
|
40
|
-
T.class_of(LogStruct::Log::SQL)
|
44
|
+
T.class_of(LogStruct::Log::SQL),
|
45
|
+
T.class_of(LogStruct::Log::Ahoy),
|
46
|
+
T.class_of(LogStruct::Log::ActiveModelSerializers)
|
41
47
|
)
|
42
48
|
end
|
43
49
|
end
|
data/lib/log_struct/version.rb
CHANGED
data/logstruct.gemspec
CHANGED
@@ -47,6 +47,8 @@ Gem::Specification.new do |spec|
|
|
47
47
|
spec.add_development_dependency "shrine", "~> 3.5"
|
48
48
|
spec.add_development_dependency "sidekiq", "~> 7.2"
|
49
49
|
spec.add_development_dependency "sorbet", "~> 0.5"
|
50
|
+
spec.add_development_dependency "ahoy_matey", "~> 5.2"
|
51
|
+
spec.add_development_dependency "active_model_serializers", "~> 0.10.13"
|
50
52
|
|
51
53
|
spec.metadata["rubygems_mfa_required"] = "true"
|
52
54
|
end
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: logstruct
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0
|
4
|
+
version: 0.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- DocSpring
|
8
8
|
bindir: exe
|
9
9
|
cert_chain: []
|
10
|
-
date: 2025-09-
|
10
|
+
date: 2025-09-06 00:00:00.000000000 Z
|
11
11
|
dependencies:
|
12
12
|
- !ruby/object:Gem::Dependency
|
13
13
|
name: lograge
|
@@ -177,6 +177,34 @@ dependencies:
|
|
177
177
|
- - "~>"
|
178
178
|
- !ruby/object:Gem::Version
|
179
179
|
version: '0.5'
|
180
|
+
- !ruby/object:Gem::Dependency
|
181
|
+
name: ahoy_matey
|
182
|
+
requirement: !ruby/object:Gem::Requirement
|
183
|
+
requirements:
|
184
|
+
- - "~>"
|
185
|
+
- !ruby/object:Gem::Version
|
186
|
+
version: '5.2'
|
187
|
+
type: :development
|
188
|
+
prerelease: false
|
189
|
+
version_requirements: !ruby/object:Gem::Requirement
|
190
|
+
requirements:
|
191
|
+
- - "~>"
|
192
|
+
- !ruby/object:Gem::Version
|
193
|
+
version: '5.2'
|
194
|
+
- !ruby/object:Gem::Dependency
|
195
|
+
name: active_model_serializers
|
196
|
+
requirement: !ruby/object:Gem::Requirement
|
197
|
+
requirements:
|
198
|
+
- - "~>"
|
199
|
+
- !ruby/object:Gem::Version
|
200
|
+
version: 0.10.13
|
201
|
+
type: :development
|
202
|
+
prerelease: false
|
203
|
+
version_requirements: !ruby/object:Gem::Requirement
|
204
|
+
requirements:
|
205
|
+
- - "~>"
|
206
|
+
- !ruby/object:Gem::Version
|
207
|
+
version: 0.10.13
|
180
208
|
description: An opinionated and type-safe structured logging solution. Configures
|
181
209
|
any Rails app to log JSON to stdout. Structured logging is automatically configured
|
182
210
|
for many gems, including Sidekiq, Carrierwave, Shrine, etc. Log messages, params,
|
@@ -215,8 +243,10 @@ files:
|
|
215
243
|
- lib/log_struct/integrations/action_mailer/metadata_collection.rb
|
216
244
|
- lib/log_struct/integrations/active_job.rb
|
217
245
|
- lib/log_struct/integrations/active_job/log_subscriber.rb
|
246
|
+
- lib/log_struct/integrations/active_model_serializers.rb
|
218
247
|
- lib/log_struct/integrations/active_record.rb
|
219
248
|
- lib/log_struct/integrations/active_storage.rb
|
249
|
+
- lib/log_struct/integrations/ahoy.rb
|
220
250
|
- lib/log_struct/integrations/carrierwave.rb
|
221
251
|
- lib/log_struct/integrations/good_job.rb
|
222
252
|
- lib/log_struct/integrations/good_job/log_subscriber.rb
|
@@ -234,13 +264,16 @@ files:
|
|
234
264
|
- lib/log_struct/log.rb
|
235
265
|
- lib/log_struct/log/action_mailer.rb
|
236
266
|
- lib/log_struct/log/active_job.rb
|
267
|
+
- lib/log_struct/log/active_model_serializers.rb
|
237
268
|
- lib/log_struct/log/active_storage.rb
|
269
|
+
- lib/log_struct/log/ahoy.rb
|
238
270
|
- lib/log_struct/log/carrierwave.rb
|
239
271
|
- lib/log_struct/log/error.rb
|
240
272
|
- lib/log_struct/log/good_job.rb
|
241
273
|
- lib/log_struct/log/interfaces/additional_data_field.rb
|
242
274
|
- lib/log_struct/log/interfaces/common_fields.rb
|
243
275
|
- lib/log_struct/log/interfaces/message_field.rb
|
276
|
+
- lib/log_struct/log/interfaces/public_common_fields.rb
|
244
277
|
- lib/log_struct/log/interfaces/request_fields.rb
|
245
278
|
- lib/log_struct/log/plain.rb
|
246
279
|
- lib/log_struct/log/request.rb
|
@@ -248,6 +281,7 @@ files:
|
|
248
281
|
- lib/log_struct/log/shared/add_request_fields.rb
|
249
282
|
- lib/log_struct/log/shared/merge_additional_data_fields.rb
|
250
283
|
- lib/log_struct/log/shared/serialize_common.rb
|
284
|
+
- lib/log_struct/log/shared/serialize_common_public.rb
|
251
285
|
- lib/log_struct/log/shrine.rb
|
252
286
|
- lib/log_struct/log/sidekiq.rb
|
253
287
|
- lib/log_struct/log/sql.rb
|