Indent logging output on nested tasks
This commit is contained in:
parent
2d4e04b2e5
commit
85ee79ab88
@ -13,3 +13,8 @@ Feature: nested tasks
|
||||
Scenario: applies nested tasks
|
||||
When I successfully execute the recipe
|
||||
Then the output must match /\AOK/
|
||||
|
||||
Scenario: indents logging from nested tasks
|
||||
When I successfully execute the recipe with option -v
|
||||
Then the output must match /^ Task:.+/
|
||||
And the output must match /^ action:.+/
|
||||
|
@ -14,20 +14,28 @@ module Producer
|
||||
tasks.each { |t| process_task t }
|
||||
end
|
||||
|
||||
def process_task(task)
|
||||
def process_task(task, indent_level = 0)
|
||||
if task.condition_met?
|
||||
@env.log "Task: `#{task}' applying..."
|
||||
log "Task: `#{task}' applying...", indent_level
|
||||
task.actions.each do |e|
|
||||
case e
|
||||
when Task then process_task e
|
||||
when Task then process_task e, indent_level + 2
|
||||
else
|
||||
@env.log " action: #{e}"
|
||||
log " action: #{e}", indent_level
|
||||
e.apply unless @env.dry_run?
|
||||
end
|
||||
end
|
||||
else
|
||||
@env.log "Task: `#{task}' skipped"
|
||||
end
|
||||
log "Task: `#{task}' skipped", indent_level
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
private
|
||||
|
||||
def log(message, indent_level)
|
||||
message = [' ' * indent_level, message].join
|
||||
@env.log message
|
||||
end
|
||||
end
|
||||
end
|
||||
|
Loading…
x
Reference in New Issue
Block a user