From 05494b7861e7883d273d42c30a7bc799c5384873 Mon Sep 17 00:00:00 2001 From: elijah Date: Sat, 2 Feb 2013 01:43:03 -0800 Subject: logging - output of leap command is now additionally sent to --log=FILE command line switch or @log value in Leapfile. --- lib/leap_cli/log.rb | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) (limited to 'lib/leap_cli/log.rb') diff --git a/lib/leap_cli/log.rb b/lib/leap_cli/log.rb index 0bc48a1..e111693 100644 --- a/lib/leap_cli/log.rb +++ b/lib/leap_cli/log.rb @@ -1,4 +1,5 @@ require 'paint' +require 'tee' ## ## LOGGING @@ -23,6 +24,21 @@ module LeapCli def indent_level=(value) @indent_level = value end + + def log_file + @log_file + end + def log_file=(value) + @log_file = value + if value + @log_output_stream = Tee.open(@log_file, :mode => 'a') + end + end + + def log_output_stream + @log_output_stream || STDOUT + end + end @@ -92,7 +108,7 @@ module LeapCli line += "[%s] " % options[:host] end line += "#{message}\n" - print line + LeapCli.log_output_stream.print(line) if block_given? LeapCli.indent_level += 1 yield -- cgit v1.2.3