Module: Beautiful::Log::TaskLogging

Defined in:
lib/beautiful/log/task_logging.rb

Instance Method Summary collapse

Instance Method Details

#task(*args) ⇒ Object



5
6
7
8
9
10
11
12
13
14
15
16
17
18
# File 'lib/beautiful/log/task_logging.rb', line 5

def task(*args)
  Rake::Task.define_task(*args) do |task, task_args|
    if block_given?
      Rails.logger&.debug "[#{task.name} #{task.comment}] started"
      begin
        yield(task, task_args)
        Rails.logger&.debug "[#{task.name} #{task.comment}] finished"
      rescue => e
        Rails.logger&.error e
        raise e # passthrough
      end
    end
  end
end