Class: LogStruct::Log::Sidekiq
- Inherits:
-
T::Struct
- Object
- T::Struct
- LogStruct::Log::Sidekiq
- Extended by:
- T::Sig
- Defined in:
- lib/log_struct/log/sidekiq.rb
Instance Attribute Summary collapse
-
#context ⇒ Hash{Symbol => T.untyped}?
readonly
Returns the value of prop
context. -
#event ⇒ Event
readonly
Returns the value of prop
event. -
#level ⇒ Level
readonly
Returns the value of prop
level. -
#message ⇒ String?
readonly
Event-specific fields.
-
#process_id ⇒ Integer?
readonly
Returns the value of prop
process_id. -
#source ⇒ Source::Sidekiq
readonly
Shared/common fields.
-
#thread_id ⇒ Integer, ...
readonly
Returns the value of prop
thread_id. -
#timestamp ⇒ Time
readonly
Returns the value of prop
timestamp.
Instance Method Summary collapse
- #initialize(source: Source::Sidekiq, event: Event::Log, timestamp:, level: Level::Info, message: nil, context: nil, process_id: nil, thread_id: nil) ⇒ void constructor
- #to_h ⇒ Hash{LogStruct::LogField => T.untyped}
Methods included from LogStruct::Log::Shared::SerializeCommon
#as_json, #serialize, #serialize_common
Methods included from Interfaces::CommonFields
Constructor Details
#initialize(source: Source::Sidekiq, event: Event::Log, timestamp:, level: Level::Info, message: nil, context: nil, process_id: nil, thread_id: nil) ⇒ void
|
|
# File '' const :source, Source::Sidekiq, default: Source::Sidekiq const :event, Event, default: Event::Log const :timestamp, Time, factory: -> { Time.now } const :level, Level, default: Level::Info const :message, T.nilable(String), default: nil const :context, T.nilable(T::Hash[Symbol, T.untyped]), default: nil const :process_id, T.nilable(Integer), default: nil const :thread_id, T.nilable(T.any(Integer, String)), default: nil |
Instance Attribute Details
#context ⇒ Hash{Symbol => T.untyped}? (readonly)
Returns the value of prop context.
|
|
# File '' const :context, T.nilable(T::Hash[Symbol, T.untyped]), default: nil |
#event ⇒ Event (readonly)
Returns the value of prop event.
|
|
# File '' const :event, Event, default: Event::Log |
#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, T.nilable(String), default: nil |
#process_id ⇒ Integer? (readonly)
Returns the value of prop process_id.
|
|
# File '' const :process_id, T.nilable(Integer), default: nil |
#source ⇒ Source::Sidekiq (readonly)
Shared/common fields
|
|
# File '' const :source, Source::Sidekiq, default: Source::Sidekiq |
#thread_id ⇒ Integer, ... (readonly)
Returns the value of prop thread_id.
|
|
# File '' const :thread_id, T.nilable(T.any(Integer, String)), default: nil |
#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}
42 43 44 45 46 47 48 49 |
# File 'lib/log_struct/log/sidekiq.rb', line 42 def to_h h = T.let({}, T::Hash[LogStruct::LogField, T.untyped]) h[LogField::Message] = unless .nil? h[LogField::Context] = context unless context.nil? h[LogField::ProcessId] = process_id unless process_id.nil? h[LogField::ThreadId] = thread_id unless thread_id.nil? h end |