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.
- data/lib/hero/observer.rb +9 -5
- 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(:
|
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,
|
66
|
+
log_step(:error, step, context, options, ex)
|
67
67
|
raise ex
|
68
68
|
end
|
69
|
-
log_step(:
|
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(
|
81
|
+
def log_step(id, step, context, options, error=nil)
|
82
82
|
return unless Hero.logger
|
83
|
-
|
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
|