lib/scout/command.rb in scout-5.1.5 vs lib/scout/command.rb in scout-5.2.1

- old
+ new

@@ -1,9 +1,8 @@ #!/usr/bin/env ruby -wKU require "optparse" -require "logger" require "fileutils" module Scout class Command def self.user @@ -35,10 +34,13 @@ opts.separator " #{program_name} [OPTIONS] run CLIENT_KEY" opts.separator " Install:" opts.separator " #{program_name}" opts.separator " ... OR ..." opts.separator " #{program_name} [OPTIONS] install" + opts.separator " Troubleshoot:" + opts.separator " #{program_name} troubleshoot" + opts.separator " ... print Scout environment info. Recommend directing output to a file." opts.separator " Local plugin testing:" opts.separator " #{program_name} [OPTIONS] test " + "PATH_TO_PLUGIN [PLUGIN_OPTIONS]" opts.separator "[PLUGIN_OPTIONS] format: opt1=val1 opt2=val2 opt2=val3 ..." opts.separator "Plugin will use internal defaults if options aren't provided." @@ -134,33 +136,37 @@ @verbose = options[:verbose] || false @level = options[:level] || "info" @force = options[:force] || false @args = args - end - attr_reader :server, :history - - def config_dir - return @config_dir if defined? @config_dir + # create config dir if necessary @config_dir = File.dirname(history) FileUtils.mkdir_p(@config_dir) # ensure dir exists - @config_dir + + @log_path = File.join(@config_dir, "latest_run.log") + end + attr_reader :server, :history, :config_dir, :log_path + + def verbose? @verbose end def log return @log if defined? @log @log = if verbose? - log = Logger.new($stdout) + log = ScoutLogger.new($stdout) log.datetime_format = "%Y-%m-%d %H:%M:%S " log.level = level log else - nil + log = ScoutLogger.new(nil) + log.datetime_format = "%Y-%m-%d %H:%M:%S " + log.level = Logger::DEBUG + log end end def level Logger.const_get(@level.upcase) rescue Logger::INFO