lib/bauxite/loggers/composite.rb in bauxite-0.6.1 vs lib/bauxite/loggers/composite.rb in bauxite-0.6.2
- old
+ new
@@ -40,13 +40,11 @@
# This implementation only yileds in the first logger.
#
# Additional loggers are called after the block completed.
#
def log_cmd(action, &block)
- ret = @loggers[0].log_cmd(action, &block)
- @loggers[1..-1].each { |l| l.log_cmd(action) { ret } }
- ret
+ _log_cmd_block(@loggers, action, &block)
end
# Returns a colorized debug prompt.
#
# This implementation returns the debug_prompt of the first logger.
@@ -65,6 +63,20 @@
# See Bauxite::Loggers::NullLogger#print
#
def log(s, type = :info)
@loggers.each { |l| l.log(s, type) }
end
+
+ # Completes the log execution.
+ #
+ def finalize(ctx)
+ @loggers.each { |l| l.finalize(ctx) }
+ end
+
+private
+ def _log_cmd_block(loggers, action, &block)
+ return yield if loggers.size == 0
+ return loggers[0].log_cmd(action, &block) if loggers.size == 1
+ loggers[0].log_cmd(action) { _log_cmd_block(loggers[1..-1], action, &block) }
+ end
+
end
\ No newline at end of file