hero 0.1.0 → 0.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. data/lib/hero/observer.rb +9 -5
  2. metadata +1 -1
data/lib/hero/observer.rb CHANGED
@@ -59,14 +59,14 @@ module Hero
59
59
  # @param optional [Hash] options An option Hash to be passed to each step.
60
60
  def update(context=nil, options={})
61
61
  steps.each do |step|
62
- log_step(:info, :before, step, context, options)
62
+ log_step(:before, step, context, options)
63
63
  begin
64
64
  step.last.call(context, options)
65
65
  rescue Exception => ex
66
- log_step(:error, :after, step, context, options)
66
+ log_step(:error, step, context, options, ex)
67
67
  raise ex
68
68
  end
69
- log_step(:info, :after, step, context, options)
69
+ log_step(:after, step, context, options)
70
70
  end
71
71
  end
72
72
 
@@ -78,9 +78,13 @@ module Hero
78
78
  # @param [Object] step
79
79
  # @param [Object] context
80
80
  # @param [Object] options
81
- def log_step(level, id, step, context, options)
81
+ def log_step(id, step, context, options, error=nil)
82
82
  return unless Hero.logger
83
- Hero.logger.send level, "HERO #{id.to_s.ljust(6)} #{formula_name} -> #{step.first} Context: #{context.inspect} Options: #{options.inspect}"
83
+ if error
84
+ Hero.logger.error "HERO #{id.to_s.ljust(6)} #{formula_name} -> #{step.first} Context: #{context.inspect} Options: #{options.inspect} Error: #{error.message}"
85
+ else
86
+ Hero.logger.info "HERO #{id.to_s.ljust(6)} #{formula_name} -> #{step.first} Context: #{context.inspect} Options: #{options.inspect}"
87
+ end
84
88
  end
85
89
 
86
90
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: hero
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors: