Class: LogStruct::Log::CarrierWave
- Inherits:
-
T::Struct
- Object
- T::Struct
- LogStruct::Log::CarrierWave
- Extended by:
- T::Sig
- Includes:
- Interfaces::AdditionalDataField, Interfaces::CommonFields, MergeAdditionalDataFields, SerializeCommon
- Defined in:
- lib/log_struct/log/carrierwave.rb
Overview
CarrierWave log entry for structured logging
Constant Summary collapse
- CarrierWaveEvent =
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
. -
#duration ⇒ Float?
readonly
Returns the value of prop
duration
. -
#event ⇒ CarrierWaveEvent
readonly
Returns the value of prop
event
. -
#file_id ⇒ String?
readonly
Returns the value of prop
file_id
. -
#filename ⇒ String?
readonly
Returns the value of prop
filename
. -
#level ⇒ Level
readonly
Returns the value of prop
level
. -
#metadata ⇒ Hash{String => T.untyped}?
readonly
Returns the value of prop
metadata
. -
#mime_type ⇒ String?
readonly
Returns the value of prop
mime_type
. -
#model ⇒ String?
readonly
Returns the value of prop
model
. -
#mount_point ⇒ String?
readonly
Returns the value of prop
mount_point
. -
#operation ⇒ Symbol?
readonly
File-specific fields.
-
#size ⇒ Integer?
readonly
Returns the value of prop
size
. -
#source ⇒ Source::CarrierWave
readonly
Common fields.
-
#storage ⇒ String?
readonly
Returns the value of prop
storage
. -
#timestamp ⇒ Time
readonly
Returns the value of prop
timestamp
. -
#uploader ⇒ String?
readonly
CarrierWave-specific fields.
Instance Method Summary collapse
- #initialize(source: T.let(Source::CarrierWave, Source::CarrierWave), event:, timestamp:, level: T.let(Level::Info, Level), operation: nil, storage: nil, file_id: nil, filename: nil, mime_type: nil, size: nil, metadata: nil, duration: nil, uploader: nil, model: nil, mount_point: 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::CarrierWave, Source::CarrierWave), event:, timestamp:, level: T.let(Level::Info, Level), operation: nil, storage: nil, file_id: nil, filename: nil, mime_type: nil, size: nil, metadata: nil, duration: nil, uploader: nil, model: nil, mount_point: nil, additional_data: {}) ⇒ void
|
# File '' const :source, Source::CarrierWave, default: T.let(Source::CarrierWave, Source::CarrierWave) const :event, CarrierWaveEvent const :timestamp, Time, factory: -> { Time.now } const :level, Level, default: T.let(Level::Info, Level) const :operation, T.nilable(Symbol), default: nil const :storage, T.nilable(String), default: nil const :file_id, T.nilable(String), default: nil const :filename, T.nilable(String), default: nil const :mime_type, T.nilable(String), default: nil const :size, T.nilable(Integer), default: nil const :metadata, T.nilable(T::Hash[String, T.untyped]), default: nil const :duration, T.nilable(Float), default: nil const :uploader, T.nilable(String), default: nil const :model, T.nilable(String), default: nil const :mount_point, T.nilable(String), 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: {} |
#duration ⇒ Float? (readonly)
Returns the value of prop duration
.
|
# File '' const :duration, T.nilable(Float), default: nil |
#event ⇒ CarrierWaveEvent (readonly)
Returns the value of prop event
.
|
# File '' const :event, CarrierWaveEvent |
#file_id ⇒ String? (readonly)
Returns the value of prop file_id
.
|
# File '' const :file_id, T.nilable(String), default: nil |
#filename ⇒ String? (readonly)
Returns the value of prop filename
.
|
# File '' const :filename, T.nilable(String), default: nil |
#level ⇒ Level (readonly)
Returns the value of prop level
.
|
# File '' const :level, Level, default: T.let(Level::Info, Level) |
#metadata ⇒ Hash{String => T.untyped}? (readonly)
Returns the value of prop metadata
.
|
# File '' const :metadata, T.nilable(T::Hash[String, T.untyped]), default: nil |
#mime_type ⇒ String? (readonly)
Returns the value of prop mime_type
.
|
# File '' const :mime_type, T.nilable(String), default: nil |
#model ⇒ String? (readonly)
Returns the value of prop model
.
|
# File '' const :model, T.nilable(String), default: nil |
#mount_point ⇒ String? (readonly)
Returns the value of prop mount_point
.
|
# File '' const :mount_point, T.nilable(String), default: nil |
#operation ⇒ Symbol? (readonly)
File-specific fields
|
# File '' const :operation, T.nilable(Symbol), default: nil |
#size ⇒ Integer? (readonly)
Returns the value of prop size
.
|
# File '' const :size, T.nilable(Integer), default: nil |
#source ⇒ Source::CarrierWave (readonly)
Common fields
|
# File '' const :source, Source::CarrierWave, default: T.let(Source::CarrierWave, Source::CarrierWave) |
#storage ⇒ String? (readonly)
Returns the value of prop storage
.
|
# File '' const :storage, T.nilable(String), default: nil |
#timestamp ⇒ Time (readonly)
Returns the value of prop timestamp
.
|
# File '' const :timestamp, Time, factory: -> { Time.now } |
#uploader ⇒ String? (readonly)
CarrierWave-specific fields
|
# 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
59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 |
# File 'lib/log_struct/log/carrierwave.rb', line 59 def serialize(strict = true) hash = serialize_common(strict) merge_additional_data_fields(hash) # Add file-specific fields if they're present hash[LOG_KEYS.fetch(:storage)] = storage if storage hash[LOG_KEYS.fetch(:operation)] = operation if operation hash[LOG_KEYS.fetch(:file_id)] = file_id if file_id hash[LOG_KEYS.fetch(:filename)] = filename if filename hash[LOG_KEYS.fetch(:mime_type)] = mime_type if mime_type hash[LOG_KEYS.fetch(:size)] = size if size hash[LOG_KEYS.fetch(:metadata)] = if hash[LOG_KEYS.fetch(:duration)] = duration if duration # Add CarrierWave-specific fields if they're present hash[LOG_KEYS.fetch(:uploader)] = uploader if uploader hash[LOG_KEYS.fetch(:model)] = model if model hash[LOG_KEYS.fetch(:mount_point)] = mount_point if mount_point hash end |