Class: LogStruct::Log::Puma::Shutdown

Inherits:
T::Struct
  • Object
show all
Extended by:
T::Sig
Includes:
Interfaces::AdditionalDataField, Interfaces::CommonFields, Shared::MergeAdditionalDataFields, Shared::SerializeCommon
Defined in:
lib/log_struct/log/puma/shutdown.rb

Constant Summary collapse

FIELD_KEYS =
T.let(
  [LogField::ProcessId].to_set(&:serialize).freeze,
  T::Set[Symbol]
)

Constants included from Shared::MergeAdditionalDataFields

Shared::MergeAdditionalDataFields::NO_FIELD_KEYS, Shared::MergeAdditionalDataFields::RESERVED_KEYS

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Shared::SerializeCommon

#as_json, #serialize, #serialize_common

Methods included from Shared::MergeAdditionalDataFields

#merge_additional_data_fields

Methods included from Interfaces::CommonFieldBase

#serialize

Constructor Details

#initialize(source: Source::Puma, event: Event::Shutdown, timestamp:, level: Level::Info, process_id: nil, additional_data: nil) ⇒ void

Parameters:

  • source (Source::Puma) (defaults to: Source::Puma) —

    Shared/common fields

  • event (Event) (defaults to: Event::Shutdown)
  • timestamp (Time)
  • level (Level) (defaults to: Level::Info)
  • process_id (Integer, nil) (defaults to: nil) —

    Event-specific fields

  • additional_data (Hash{String, Symbol => T.untyped}, nil) (defaults to: nil) —

    Additional data



# File ''

const :source, Source::Puma, default: Source::Puma, override: true
const :event, Event, default: Event::Shutdown, override: true
const :timestamp, Time, factory: -> { Time.now }, override: true
const :level, Level, default: Level::Info, override: true
const :process_id, T.nilable(Integer), default: nil
const :additional_data, T.nilable(T::Hash[T.any(String, Symbol), T.untyped]), default: nil, override: true

Instance Attribute Details

#additional_data ⇒ Hash{String, Symbol => T.untyped}? (readonly)

Additional data

Returns:

  • (Hash{String, Symbol => T.untyped}, nil)


# File ''

const :additional_data, T.nilable(T::Hash[T.any(String, Symbol), T.untyped]), default: nil, override: true

#event ⇒ Event (readonly)

Returns the value of prop event.

Returns:



# File ''

const :event, Event, default: Event::Shutdown, override: true

#level ⇒ Level (readonly)

Returns the value of prop level.

Returns:



# File ''

const :level, Level, default: Level::Info, override: true

#process_id ⇒ Integer? (readonly)

Event-specific fields

Returns:

  • (Integer, nil)


# File ''

const :process_id, T.nilable(Integer), default: nil

#source ⇒ Source::Puma (readonly)

Shared/common fields

Returns:



# File ''

const :source, Source::Puma, default: Source::Puma, override: true

#timestamp ⇒ Time (readonly)

Returns the value of prop timestamp.

Returns:

  • (Time)


# File ''

const :timestamp, Time, factory: -> { Time.now }, override: true

Instance Method Details

#field_keys ⇒ Set<Symbol>

Returns:

  • (Set<Symbol>)


49
50
51
# File 'lib/log_struct/log/puma/shutdown.rb', line 49

def field_keys
  FIELD_KEYS
end

#to_h ⇒ Hash{LogStruct::LogField => T.untyped}

Returns:



57
58
59
60
61
# File 'lib/log_struct/log/puma/shutdown.rb', line 57

def to_h
  h = T.let({}, T::Hash[LogStruct::LogField, T.untyped])
  h[LogField::ProcessId] = process_id unless process_id.nil?
  h
end