Class: LogStruct::Log::Shrine
- Inherits:
-
T::Struct
- Object
- T::Struct
- LogStruct::Log::Shrine
- Extended by:
- T::Sig
- Includes:
- Interfaces::AdditionalDataField, Interfaces::CommonFields, MergeAdditionalDataFields, SerializeCommon
- Defined in:
- lib/log_struct/log/shrine.rb
Overview
Shrine log entry for structured logging
Constant Summary collapse
- ShrineEvent =
T.type_alias { T.any( Event::Upload, Event::Download, Event::Delete, Event::Metadata, Event::Exist, Event::Unknown ) }
Instance Attribute Summary collapse
-
#additional_data ⇒ Hash{Symbol => T.untyped}
readonly
Returns the value of prop
additional_data
. -
#download_options ⇒ Hash{Symbol => T.untyped}?
readonly
Returns the value of prop
download_options
. -
#duration ⇒ Float?
readonly
Returns the value of prop
duration
. -
#event ⇒ ShrineEvent
readonly
Returns the value of prop
event
. -
#level ⇒ Level
readonly
Returns the value of prop
level
. -
#location ⇒ String?
readonly
Returns the value of prop
location
. -
#options ⇒ Hash{Symbol => T.untyped}?
readonly
Returns the value of prop
options
. -
#source ⇒ Source::Shrine
readonly
Common fields.
-
#storage ⇒ String?
readonly
Shrine-specific fields.
-
#timestamp ⇒ Time
readonly
Returns the value of prop
timestamp
. -
#upload_options ⇒ Hash{Symbol => T.untyped}?
readonly
Returns the value of prop
upload_options
. -
#uploader ⇒ String?
readonly
Returns the value of prop
uploader
.
Instance Method Summary collapse
- #initialize(source: T.let(Source::Shrine, Source::Shrine), event:, timestamp:, level: T.let(Level::Info, Level), storage: nil, location: nil, upload_options: nil, download_options: nil, options: nil, uploader: nil, duration: nil, additional_data: {}) ⇒ void constructor
-
#serialize(strict = true) ⇒ Hash{Symbol => T.untyped}
Convert the log entry to a hash for serialization.
Methods included from MergeAdditionalDataFields
Methods included from SerializeCommon
Constructor Details
#initialize(source: T.let(Source::Shrine, Source::Shrine), event:, timestamp:, level: T.let(Level::Info, Level), storage: nil, location: nil, upload_options: nil, download_options: nil, options: nil, uploader: nil, duration: nil, additional_data: {}) ⇒ void
|
# File '' const :source, Source::Shrine, default: T.let(Source::Shrine, Source::Shrine) const :event, ShrineEvent const :timestamp, Time, factory: -> { Time.now } const :level, Level, default: T.let(Level::Info, Level) const :storage, T.nilable(String), default: nil const :location, T.nilable(String), default: nil const :upload_options, T.nilable(T::Hash[Symbol, T.untyped]), default: nil const :download_options, T.nilable(T::Hash[Symbol, T.untyped]), default: nil const :options, T.nilable(T::Hash[Symbol, T.untyped]), default: nil const :uploader, T.nilable(String), default: nil const :duration, T.nilable(Float), default: nil const :additional_data, T::Hash[Symbol, T.untyped], default: {} |
Instance Attribute Details
#additional_data ⇒ Hash{Symbol => T.untyped} (readonly)
Returns the value of prop additional_data
.
|
# File '' const :additional_data, T::Hash[Symbol, T.untyped], default: {} |
#download_options ⇒ Hash{Symbol => T.untyped}? (readonly)
Returns the value of prop download_options
.
|
# File '' const :download_options, T.nilable(T::Hash[Symbol, T.untyped]), default: nil |
#duration ⇒ Float? (readonly)
Returns the value of prop duration
.
|
# File '' const :duration, T.nilable(Float), default: nil |
#event ⇒ ShrineEvent (readonly)
Returns the value of prop event
.
|
# File '' const :event, ShrineEvent |
#level ⇒ Level (readonly)
Returns the value of prop level
.
|
# File '' const :level, Level, default: T.let(Level::Info, Level) |
#location ⇒ String? (readonly)
Returns the value of prop location
.
|
# File '' const :location, T.nilable(String), default: nil |
#options ⇒ Hash{Symbol => T.untyped}? (readonly)
Returns the value of prop options
.
|
# File '' const :options, T.nilable(T::Hash[Symbol, T.untyped]), default: nil |
#source ⇒ Source::Shrine (readonly)
Common fields
|
# File '' const :source, Source::Shrine, default: T.let(Source::Shrine, Source::Shrine) |
#storage ⇒ String? (readonly)
Shrine-specific fields
|
# File '' const :storage, T.nilable(String), default: nil |
#timestamp ⇒ Time (readonly)
Returns the value of prop timestamp
.
|
# File '' const :timestamp, Time, factory: -> { Time.now } |
#upload_options ⇒ Hash{Symbol => T.untyped}? (readonly)
Returns the value of prop upload_options
.
|
# File '' const :upload_options, T.nilable(T::Hash[Symbol, T.untyped]), default: nil |
#uploader ⇒ String? (readonly)
Returns the value of prop uploader
.
|
# File '' const :uploader, T.nilable(String), default: nil |
Instance Method Details
#serialize(strict = true) ⇒ Hash{Symbol => T.untyped}
Convert the log entry to a hash for serialization
53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 |
# File 'lib/log_struct/log/shrine.rb', line 53 def serialize(strict = true) hash = serialize_common(strict) merge_additional_data_fields(hash) # Add Shrine-specific fields if they're present hash[LOG_KEYS.fetch(:storage)] = storage if storage hash[LOG_KEYS.fetch(:location)] = location if location hash[LOG_KEYS.fetch(:upload_options)] = if hash[LOG_KEYS.fetch(:download_options)] = if hash[LOG_KEYS.fetch(:options)] = if hash[LOG_KEYS.fetch(:uploader)] = uploader if uploader hash[LOG_KEYS.fetch(:duration)] = duration if duration hash end |