aboutsummaryrefslogtreecommitdiff
path: root/lib/leap_cli/log.rb
diff options
context:
space:
mode:
authorelijah <elijah@riseup.net>2013-02-02 01:43:03 -0800
committerelijah <elijah@riseup.net>2013-02-02 01:43:03 -0800
commit05494b7861e7883d273d42c30a7bc799c5384873 (patch)
tree32fc8776a0e25ff257e423ac4e0b4f61abc7cf6c /lib/leap_cli/log.rb
parentd0247e01c08cf2ce0fefb5808f11c824b681d61f (diff)
downloadleap_cli-05494b7861e7883d273d42c30a7bc799c5384873.tar.gz
leap_cli-05494b7861e7883d273d42c30a7bc799c5384873.tar.bz2
logging - output of leap command is now additionally sent to --log=FILE command line switch or @log value in Leapfile.
Diffstat (limited to 'lib/leap_cli/log.rb')
-rw-r--r--lib/leap_cli/log.rb18
1 files changed, 17 insertions, 1 deletions
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