Class: LogStruct::Log::ActiveStorage
- Inherits:
-
T::Struct
- Object
- T::Struct
- LogStruct::Log::ActiveStorage
- Extended by:
- T::Sig
- Includes:
- Interfaces::CommonFields, SerializeCommon
- Defined in:
- lib/log_struct/log/active_storage.rb
Overview
ActiveStorage log entry for structured logging
Constant Summary collapse
- ActiveStorageEvent =
Define valid event types for ActiveStorage
T.type_alias { T.any( Event::Upload, Event::Download, Event::Delete, Event::Metadata, Event::Exist, Event::Stream, Event::Url, Event::Unknown ) }
Instance Attribute Summary collapse
-
#checksum ⇒ String?
readonly
Returns the value of prop
checksum
. -
#duration ⇒ Float?
readonly
Returns the value of prop
duration
. -
#event ⇒ ActiveStorageEvent
readonly
Returns the value of prop
event
. -
#exist ⇒ Boolean?
readonly
Returns the value of prop
exist
. -
#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
. -
#operation ⇒ Symbol?
readonly
ActiveStorage-specific fields.
-
#prefix ⇒ String?
readonly
Returns the value of prop
prefix
. -
#range ⇒ String?
readonly
Returns the value of prop
range
. -
#size ⇒ Integer?
readonly
Returns the value of prop
size
. -
#source ⇒ Source::Storage
readonly
Common fields.
-
#storage ⇒ String?
readonly
Returns the value of prop
storage
. -
#timestamp ⇒ Time
readonly
Returns the value of prop
timestamp
. -
#url ⇒ String?
readonly
Returns the value of prop
url
.
Instance Method Summary collapse
- #initialize(source: T.let(Source::Storage, Source::Storage), 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, checksum: nil, exist: nil, url: nil, prefix: nil, range: nil) ⇒ void constructor
-
#serialize(strict = true) ⇒ Hash{Symbol => T.untyped}
Convert the log entry to a hash for serialization.
Methods included from SerializeCommon
Constructor Details
#initialize(source: T.let(Source::Storage, Source::Storage), 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, checksum: nil, exist: nil, url: nil, prefix: nil, range: nil) ⇒ void
|
# File '' const :source, Source::Storage, default: T.let(Source::Storage, Source::Storage) const :event, ActiveStorageEvent 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 :checksum, T.nilable(String), default: nil const :exist, T.nilable(T::Boolean), default: nil const :url, T.nilable(String), default: nil const :prefix, T.nilable(String), default: nil const :range, T.nilable(String), default: nil |
Instance Attribute Details
#checksum ⇒ String? (readonly)
Returns the value of prop checksum
.
|
# File '' const :checksum, T.nilable(String), default: nil |
#duration ⇒ Float? (readonly)
Returns the value of prop duration
.
|
# File '' const :duration, T.nilable(Float), default: nil |
#event ⇒ ActiveStorageEvent (readonly)
Returns the value of prop event
.
|
# File '' const :event, ActiveStorageEvent |
#exist ⇒ Boolean? (readonly)
Returns the value of prop exist
.
|
# File '' const :exist, T.nilable(T::Boolean), default: nil |
#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 |
#operation ⇒ Symbol? (readonly)
ActiveStorage-specific fields
|
# File '' const :operation, T.nilable(Symbol), default: nil |
#prefix ⇒ String? (readonly)
Returns the value of prop prefix
.
|
# File '' const :prefix, T.nilable(String), default: nil |
#range ⇒ String? (readonly)
Returns the value of prop range
.
|
# File '' const :range, T.nilable(String), default: nil |
#size ⇒ Integer? (readonly)
Returns the value of prop size
.
|
# File '' const :size, T.nilable(Integer), default: nil |
#source ⇒ Source::Storage (readonly)
Common fields
|
# File '' const :source, Source::Storage, default: T.let(Source::Storage, Source::Storage) |
#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 } |
#url ⇒ String? (readonly)
Returns the value of prop url
.
|
# File '' const :url, T.nilable(String), default: nil |
Instance Method Details
#serialize(strict = true) ⇒ Hash{Symbol => T.untyped}
Convert the log entry to a hash for serialization
56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 |
# File 'lib/log_struct/log/active_storage.rb', line 56 def serialize(strict = true) hash = serialize_common(strict) # Add ActiveStorage-specific fields - only include non-nil values hash[LOG_KEYS.fetch(:operation)] = operation if operation hash[LOG_KEYS.fetch(:storage)] = storage if storage 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 hash[LOG_KEYS.fetch(:checksum)] = checksum if checksum hash[LOG_KEYS.fetch(:exist)] = exist if !exist.nil? hash[LOG_KEYS.fetch(:url)] = url if url hash[LOG_KEYS.fetch(:prefix)] = prefix if prefix hash[LOG_KEYS.fetch(:range)] = range if range hash end |