Class: LogStruct::Log::ActiveJob
- Inherits:
-
T::Struct
- Object
- T::Struct
- LogStruct::Log::ActiveJob
- Extended by:
- T::Sig
- Includes:
- Interfaces::AdditionalDataField, Interfaces::CommonFields, MergeAdditionalDataFields, SerializeCommon
- Defined in:
- lib/log_struct/log/active_job.rb
Overview
ActiveJob log entry for structured logging
Constant Summary collapse
- ActiveJobEvent =
T.type_alias { T.any( Event::Enqueue, Event::Schedule, Event::Start, Event::Finish ) }
Instance Attribute Summary collapse
-
#additional_data ⇒ Hash{Symbol => T.untyped}
readonly
Returns the value of prop
additional_data
. -
#arguments ⇒ Array<T.untyped>?
readonly
Returns the value of prop
arguments
. -
#duration ⇒ Float?
readonly
Returns the value of prop
duration
. -
#event ⇒ ActiveJobEvent
readonly
Returns the value of prop
event
. -
#job_class ⇒ String?
readonly
Returns the value of prop
job_class
. -
#job_id ⇒ String?
readonly
Job-specific fields.
-
#level ⇒ Level
readonly
Returns the value of prop
level
. -
#queue_name ⇒ String?
readonly
Returns the value of prop
queue_name
. -
#source ⇒ Source::Job
readonly
Common fields.
-
#timestamp ⇒ Time
readonly
Returns the value of prop
timestamp
.
Instance Method Summary collapse
- #initialize(source: T.let(Source::Job, Source::Job), event:, timestamp:, level: T.let(Level::Info, Level), job_id: nil, job_class: nil, queue_name: nil, arguments: 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::Job, Source::Job), event:, timestamp:, level: T.let(Level::Info, Level), job_id: nil, job_class: nil, queue_name: nil, arguments: nil, duration: nil, additional_data: {}) ⇒ void
|
# File '' const :source, Source::Job, default: T.let(Source::Job, Source::Job) const :event, ActiveJobEvent const :timestamp, Time, factory: -> { Time.now } const :level, Level, default: T.let(Level::Info, Level) const :job_id, T.nilable(String), default: nil const :job_class, T.nilable(String), default: nil const :queue_name, T.nilable(String), default: nil const :arguments, T.nilable(T::Array[T.untyped]), 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: {} |
#arguments ⇒ Array<T.untyped>? (readonly)
Returns the value of prop arguments
.
|
# File '' const :arguments, T.nilable(T::Array[T.untyped]), default: nil |
#duration ⇒ Float? (readonly)
Returns the value of prop duration
.
|
# File '' const :duration, T.nilable(Float), default: nil |
#event ⇒ ActiveJobEvent (readonly)
Returns the value of prop event
.
|
# File '' const :event, ActiveJobEvent |
#job_class ⇒ String? (readonly)
Returns the value of prop job_class
.
|
# File '' const :job_class, T.nilable(String), default: nil |
#job_id ⇒ String? (readonly)
Job-specific fields
|
# File '' const :job_id, T.nilable(String), default: nil |
#level ⇒ Level (readonly)
Returns the value of prop level
.
|
# File '' const :level, Level, default: T.let(Level::Info, Level) |
#queue_name ⇒ String? (readonly)
Returns the value of prop queue_name
.
|
# File '' const :queue_name, T.nilable(String), default: nil |
#source ⇒ Source::Job (readonly)
Common fields
|
# File '' const :source, Source::Job, default: T.let(Source::Job, Source::Job) |
#timestamp ⇒ Time (readonly)
Returns the value of prop timestamp
.
|
# File '' const :timestamp, Time, factory: -> { Time.now } |
Instance Method Details
#serialize(strict = true) ⇒ Hash{Symbol => T.untyped}
Convert the log entry to a hash for serialization
49 50 51 52 53 54 55 56 57 58 59 60 61 |
# File 'lib/log_struct/log/active_job.rb', line 49 def serialize(strict = true) hash = serialize_common(strict) merge_additional_data_fields(hash) # Add job-specific fields if they're present hash[LOG_KEYS.fetch(:job_id)] = job_id if job_id hash[LOG_KEYS.fetch(:job_class)] = job_class if job_class hash[LOG_KEYS.fetch(:queue_name)] = queue_name if queue_name hash[LOG_KEYS.fetch(:arguments)] = arguments if arguments hash[LOG_KEYS.fetch(:duration)] = duration if duration hash end |