Sha256: 2a346d18857e13fc2cc376d0df87f9a9a6920dc0f2d4441a1207549040a4d0a5

Contents?: true

Size: 845 Bytes

Versions: 56

Compression:

Stored size: 845 Bytes

Contents

module Actions
  module Helpers
    module LifecycleLogging
      def self.included(base)
        base.execution_plan_hooks.use :log_task_state_change
      end

      def log_task_state_change(execution_plan)
        return unless root_action?
        logger = Rails.application.dynflow.world.action_logger
        task_id = ForemanTasks::Task::DynflowTask.where(external_id: execution_plan.id).pluck(:id).first

        task_id_parts = []
        task_id_parts << "id: #{task_id}" if task_id
        task_id_parts << "execution_plan_id: #{execution_plan.id}"
        result_info = " result: #{execution_plan.result}" if [:stopped, :paused].include?(execution_plan.state)
        logger.info("Task {label: #{execution_plan.label}, #{task_id_parts.join(', ')}} state changed: #{execution_plan.state} #{result_info}")
      end
    end
  end
end

Version data entries

56 entries across 56 versions & 1 rubygems

Version Path
foreman-tasks-4.1.6 app/lib/actions/helpers/lifecycle_logging.rb
foreman-tasks-5.2.3 app/lib/actions/helpers/lifecycle_logging.rb
foreman-tasks-5.2.2 app/lib/actions/helpers/lifecycle_logging.rb
foreman-tasks-5.2.1 app/lib/actions/helpers/lifecycle_logging.rb
foreman-tasks-5.3.0 app/lib/actions/helpers/lifecycle_logging.rb
foreman-tasks-5.2.0 app/lib/actions/helpers/lifecycle_logging.rb
foreman-tasks-5.1.1 app/lib/actions/helpers/lifecycle_logging.rb
foreman-tasks-5.1.0 app/lib/actions/helpers/lifecycle_logging.rb
foreman-tasks-4.1.5 app/lib/actions/helpers/lifecycle_logging.rb
foreman-tasks-4.1.4 app/lib/actions/helpers/lifecycle_logging.rb
foreman-tasks-4.1.3 app/lib/actions/helpers/lifecycle_logging.rb
foreman-tasks-3.0.6 app/lib/actions/helpers/lifecycle_logging.rb
foreman-tasks-5.0.0 app/lib/actions/helpers/lifecycle_logging.rb
foreman-tasks-4.1.2 app/lib/actions/helpers/lifecycle_logging.rb
foreman-tasks-4.1.1 app/lib/actions/helpers/lifecycle_logging.rb
foreman-tasks-4.0.1 app/lib/actions/helpers/lifecycle_logging.rb
foreman-tasks-4.1.0 app/lib/actions/helpers/lifecycle_logging.rb
foreman-tasks-3.0.5 app/lib/actions/helpers/lifecycle_logging.rb
foreman-tasks-4.0.0 app/lib/actions/helpers/lifecycle_logging.rb
foreman-tasks-3.0.4 app/lib/actions/helpers/lifecycle_logging.rb