Class: LogStruct::Log::GoodJob::Error

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Shared::SerializeCommon

#as_json, #serialize, #serialize_common

Methods included from Interfaces::CommonFields

#serialize

Constructor Details

#initialize(source: Source::Job, event: Event::Error, timestamp:, level: Level::Info, job_id: nil, job_class: nil, queue_name: nil, arguments: nil, executions: nil, error_class:, error_message:, duration_ms: nil, process_id:, thread_id:, exception_executions: nil, backtrace: nil) ⇒ void

Parameters:

  • source (Source::Job) (defaults to: Source::Job)

    Shared/common fields

  • event (Event) (defaults to: Event::Error)
  • timestamp (Time)
  • level (Level) (defaults to: Level::Info)
  • job_id (String, nil) (defaults to: nil)
  • job_class (String, nil) (defaults to: nil)
  • queue_name (Symbol, nil) (defaults to: nil)
  • arguments (Array<T.untyped>, nil) (defaults to: nil)
  • executions (Integer, nil) (defaults to: nil)
  • error_class (String)

    Event-specific fields

  • error_message (String)
  • duration_ms (Float, nil) (defaults to: nil)
  • process_id (Integer)
  • thread_id (String)
  • exception_executions (Integer, nil) (defaults to: nil)
  • backtrace (Array<String>, nil) (defaults to: nil)


# File ''

const :source, Source::Job, default: Source::Job
const :event, Event, default: Event::Error
const :timestamp, Time, factory: -> { Time.now }
const :level, Level, default: Level::Info
const :job_id, T.nilable(String), default: nil
const :job_class, T.nilable(String), default: nil
const :queue_name, T.nilable(Symbol), default: nil
const :arguments, T.nilable(T::Array[T.untyped]), default: nil
const :executions, T.nilable(Integer), default: nil
const :error_class, String
const :error_message, String
const :duration_ms, T.nilable(Float), default: nil
const :process_id, Integer
const :thread_id, String
const :exception_executions, T.nilable(Integer), default: nil
const :backtrace, T.nilable(T::Array[String]), default: nil

Instance Attribute Details

#argumentsArray<T.untyped>? (readonly)

Returns the value of prop arguments.

Returns:

  • (Array<T.untyped>, nil)


# File ''

const :arguments, T.nilable(T::Array[T.untyped]), default: nil

#backtraceArray<String>? (readonly)

Returns the value of prop backtrace.

Returns:

  • (Array<String>, nil)


# File ''

const :backtrace, T.nilable(T::Array[String]), default: nil

#duration_msFloat? (readonly)

Returns the value of prop duration_ms.

Returns:

  • (Float, nil)


# File ''

const :duration_ms, T.nilable(Float), default: nil

#error_classString (readonly)

Event-specific fields

Returns:

  • (String)


# File ''

const :error_class, String

#error_messageString (readonly)

Returns the value of prop error_message.

Returns:

  • (String)


# File ''

const :error_message, String

#eventEvent (readonly)

Returns the value of prop event.

Returns:



# File ''

const :event, Event, default: Event::Error

#exception_executionsInteger? (readonly)

Returns the value of prop exception_executions.

Returns:

  • (Integer, nil)


# File ''

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

#executionsInteger? (readonly)

Returns the value of prop executions.

Returns:

  • (Integer, nil)


# File ''

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

#job_classString? (readonly)

Returns the value of prop job_class.

Returns:

  • (String, nil)


# File ''

const :job_class, T.nilable(String), default: nil

#job_idString? (readonly)

Returns the value of prop job_id.

Returns:

  • (String, nil)


# File ''

const :job_id, T.nilable(String), default: nil

#levelLevel (readonly)

Returns the value of prop level.

Returns:



# File ''

const :level, Level, default: Level::Info

#process_idInteger (readonly)

Returns the value of prop process_id.

Returns:

  • (Integer)


# File ''

const :process_id, Integer

#queue_nameSymbol? (readonly)

Returns the value of prop queue_name.

Returns:

  • (Symbol, nil)


# File ''

const :queue_name, T.nilable(Symbol), default: nil

#sourceSource::Job (readonly)

Shared/common fields

Returns:



# File ''

const :source, Source::Job, default: Source::Job

#thread_idString (readonly)

Returns the value of prop thread_id.

Returns:

  • (String)


# File ''

const :thread_id, String

#timestampTime (readonly)

Returns the value of prop timestamp.

Returns:

  • (Time)


# File ''

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

Instance Method Details

#to_hHash{LogStruct::LogField => T.untyped}

Returns:



52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
# File 'lib/log_struct/log/good_job/error.rb', line 52

def to_h
  h = T.let({}, T::Hash[LogStruct::LogField, T.untyped])
  h[LogField::JobId] = job_id unless job_id.nil?
  h[LogField::JobClass] = job_class unless job_class.nil?
  h[LogField::QueueName] = queue_name unless queue_name.nil?
  h[LogField::Arguments] = arguments unless arguments.nil?
  h[LogField::Executions] = executions unless executions.nil?
  h[LogField::ErrorClass] = error_class
  h[LogField::ErrorMessage] = error_message
  h[LogField::DurationMs] = duration_ms unless duration_ms.nil?
  h[LogField::ProcessId] = process_id
  h[LogField::ThreadId] = thread_id
  h[LogField::ExceptionExecutions] = exception_executions unless exception_executions.nil?
  h[LogField::Backtrace] = backtrace unless backtrace.nil?
  h
end