s.add_runtime_dependency('command_line_reporter')
s.add_runtime_dependency('highline')
s.add_runtime_dependency('paint')
+ s.add_runtime_dependency('tee')
# network gems
s.add_runtime_dependency('capistrano', '>= 2.13.5')
module Commands
desc 'Verbosity level 0..2'
- arg_name 'level'
+ arg_name 'LEVEL'
default_value '1'
flag [:v, :verbose]
+ desc 'Override default log file'
+ arg_name 'FILE'
+ default_value nil
+ flag :log
+
desc 'Display version number and exit'
switch :version, :negatable => false
bail! { log :missing, "platform directory '#{Path.platform}'" }
end
+ #
+ # set log file
+ #
+ LeapCli.log_file = global[:log] || LeapCli.leapfile.log
+
#
# load all the nodes everything
#
attr_accessor :provider_directory_path
attr_accessor :custom_vagrant_vm_line
attr_accessor :leap_version
+ attr_accessor :log
def load
directory = File.expand_path(find_in_directory_tree('Leapfile'))
require 'paint'
+require 'tee'
##
## LOGGING
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
line += "[%s] " % options[:host]
end
line += "#{message}\n"
- print line
+ LeapCli.log_output_stream.print(line)
if block_given?
LeapCli.indent_level += 1
yield