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.



177
178
179
180
# File 'lib/lazylead/model.rb', line 177

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

Instance Method Details

#execObject



182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
# File 'lib/lazylead/model.rb', line 182

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