Class: LogStruct::Log::ActiveModelSerializers
- Inherits:
-
T::Struct
- Object
- T::Struct
- LogStruct::Log::ActiveModelSerializers
- Extended by:
- T::Sig
- Includes:
- Interfaces::CommonFields, Shared::SerializeCommon
- Defined in:
- lib/log_struct/log/active_model_serializers.rb
Instance Attribute Summary collapse
-
#adapter ⇒ String?
readonly
Returns the value of prop
adapter. -
#duration_ms ⇒ Float
readonly
Returns the value of prop
duration_ms. -
#event ⇒ Event
readonly
Returns the value of prop
event. -
#level ⇒ Level
readonly
Returns the value of prop
level. -
#message ⇒ String
readonly
Event-specific fields.
-
#resource_class ⇒ String?
readonly
Returns the value of prop
resource_class. -
#serializer ⇒ String?
readonly
Returns the value of prop
serializer. -
#source ⇒ Source::Rails
readonly
Shared/common fields.
-
#timestamp ⇒ Time
readonly
Returns the value of prop
timestamp.
Instance Method Summary collapse
- #initialize(source: Source::Rails, event: Event::Generate, timestamp:, level: Level::Info, message:, serializer: nil, adapter: nil, resource_class: nil, duration_ms:) ⇒ void constructor
- #to_h ⇒ Hash{LogStruct::LogField => T.untyped}
Methods included from Shared::SerializeCommon
#as_json, #serialize, #serialize_common
Methods included from Interfaces::CommonFields
Constructor Details
#initialize(source: Source::Rails, event: Event::Generate, timestamp:, level: Level::Info, message:, serializer: nil, adapter: nil, resource_class: nil, duration_ms:) ⇒ void
|
|
# File '' const :source, Source::Rails, default: Source::Rails const :event, Event, default: Event::Generate const :timestamp, Time, factory: -> { Time.now } const :level, Level, default: Level::Info const :message, String const :serializer, T.nilable(String), default: nil const :adapter, T.nilable(String), default: nil const :resource_class, T.nilable(String), default: nil const :duration_ms, Float |
Instance Attribute Details
#adapter ⇒ String? (readonly)
Returns the value of prop adapter.
|
|
# File '' const :adapter, T.nilable(String), default: nil |
#duration_ms ⇒ Float (readonly)
Returns the value of prop duration_ms.
|
|
# File '' const :duration_ms, Float |
#event ⇒ Event (readonly)
Returns the value of prop event.
|
|
# File '' const :event, Event, default: Event::Generate |
#level ⇒ Level (readonly)
Returns the value of prop level.
|
|
# File '' const :level, Level, default: Level::Info |
#message ⇒ String (readonly)
Event-specific fields
|
|
# File '' const :message, String |
#resource_class ⇒ String? (readonly)
Returns the value of prop resource_class.
|
|
# File '' const :resource_class, T.nilable(String), default: nil |
#serializer ⇒ String? (readonly)
Returns the value of prop serializer.
|
|
# File '' const :serializer, T.nilable(String), default: nil |
#source ⇒ Source::Rails (readonly)
Shared/common fields
|
|
# File '' const :source, Source::Rails, default: Source::Rails |
#timestamp ⇒ Time (readonly)
Returns the value of prop timestamp.
|
|
# File '' const :timestamp, Time, factory: -> { Time.now } |
Instance Method Details
#to_h ⇒ Hash{LogStruct::LogField => T.untyped}
43 44 45 46 47 48 49 50 51 |
# File 'lib/log_struct/log/active_model_serializers.rb', line 43 def to_h h = T.let({}, T::Hash[LogStruct::LogField, T.untyped]) h[LogField::Message] = h[LogField::Serializer] = serializer unless serializer.nil? h[LogField::Adapter] = adapter unless adapter.nil? h[LogField::ResourceClass] = resource_class unless resource_class.nil? h[LogField::DurationMs] = duration_ms h end |