Class: Lazylead::ORM::VerboseTask

Inherits:
Object
  • Object
show all
Extended by:
Forwardable
Defined in:
lib/lazylead/model.rb

Overview

A task with extended logging

See Also:

Instance Method Summary collapse

Constructor Details

#initialize(orig, log = Log.new) ⇒ VerboseTask

Returns a new instance of VerboseTask.



180
181
182
183
# File 'lib/lazylead/model.rb', line 180

def initialize(orig, log = Log.new)
  @orig = orig
  @log = log
end

Instance Method Details

#execObject

TODO:

#/DEV Remove the suppression during next refactoring (or enhancements) for the method below

rubocop:disable Metrics/AbcSize



189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
# File 'lib/lazylead/model.rb', line 189

def exec
  Logging.mdc["tid"] = "task #{id}"
  @log.debug "'#{name}' is started."
  @log.warn "No postman, stub is used." unless props.key? "postman"
  @log.warn "No team." if team.nil?
  @orig.exec
  @log.debug "'#{name}' is completed"
rescue StandardError => e
  msg = <<~MSG
    ll-006: Task ##{id} #{e} (#{e.class}) at #{self}
    #{Backtrace.new(e) if ARGV.include? '--trace'}
  MSG
  @log.error msg
ensure
  Logging.mdc["tid"] = ""
end