Class: DeploymentTask::TaskLogger

Inherits:
Object
  • Object
show all
Defined in:
lib/deployment_task/task_logger.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(execution_id:) ⇒ TaskLogger

Returns a new instance of TaskLogger.



10
11
12
# File 'lib/deployment_task/task_logger.rb', line 10

def initialize(execution_id:)
  @execution_id = execution_id
end

Instance Attribute Details

#execution_idObject (readonly)

Returns the value of attribute execution_id.



8
9
10
# File 'lib/deployment_task/task_logger.rb', line 8

def execution_id
  @execution_id
end

Instance Method Details

#log_dry_run_entry(version:, description:, phase:, status:) ⇒ Object



51
52
53
54
# File 'lib/deployment_task/task_logger.rb', line 51

def log_dry_run_entry(version:, description:, phase:, status:)
  log(event: "dry_run_entry", version: version, description: description,
      phase: phase, current_status: status, timestamp: Time.now.utc.iso8601)
end

#log_phase_start(phase:, task_count:, dry_run:) ⇒ Object



41
42
43
44
# File 'lib/deployment_task/task_logger.rb', line 41

def log_phase_start(phase:, task_count:, dry_run:)
  log(event: "phase_start", phase: phase, task_count: task_count,
      dry_run: dry_run, timestamp: Time.now.utc.iso8601)
end

#log_phase_summary(phase:, results:) ⇒ Object



46
47
48
49
# File 'lib/deployment_task/task_logger.rb', line 46

def log_phase_summary(phase:, results:)
  log(event: "phase_summary", phase: phase, **results,
      timestamp: Time.now.utc.iso8601)
end

#log_task_complete(version:, duration:) ⇒ Object



19
20
21
22
23
# File 'lib/deployment_task/task_logger.rb', line 19

def log_task_complete(version:, duration:)
  log(event: "task_complete", version: version,
      duration_seconds: duration, status: "completed",
      timestamp: Time.now.utc.iso8601)
end

#log_task_failure(version:, error:, phase:) ⇒ Object



25
26
27
28
29
30
31
32
33
34
# File 'lib/deployment_task/task_logger.rb', line 25

def log_task_failure(version:, error:, phase:)
  payload = {
    event: "task_failure", version: version, status: "failed",
    error_class: error.class.name, error_message: error.message,
    backtrace: error.backtrace&.first(20),
    timestamp: Time.now.utc.iso8601
  }
  log(payload)
  report_error(error, version: version, phase: phase)
end

#log_task_skip(version:, description:) ⇒ Object



36
37
38
39
# File 'lib/deployment_task/task_logger.rb', line 36

def log_task_skip(version:, description:)
  log(event: "task_skip", version: version, description: description,
      status: "skipped", timestamp: Time.now.utc.iso8601)
end

#log_task_start(version:, description:, phase:) ⇒ Object



14
15
16
17
# File 'lib/deployment_task/task_logger.rb', line 14

def log_task_start(version:, description:, phase:)
  log(event: "task_start", version: version, description: description,
      phase: phase, timestamp: Time.now.utc.iso8601)
end