lib/commands/base.rb in factor-0.5.05 vs lib/commands/base.rb in factor-0.5.06

- old
+ new

@@ -5,11 +5,10 @@ require 'yaml' require 'fileutils' module Factor module Commands - # Base command with common methods used by all commands class Command DEFAULT_FILENAME = { connectors: File.expand_path('./connectors.yml'), credentials: File.expand_path('./credentials.yml') @@ -31,13 +30,10 @@ def success(options = {}) log_line :success, options end - def debug(options = {}) - end - def exception(message, exception) error 'message' => message error 'message' => " #{exception.message}" exception.backtrace.each do |line| error 'message' => " #{line}" @@ -52,15 +48,15 @@ private def load_config_data(config_type, options = {}) relative_path = options[config_type] || DEFAULT_FILENAME[config_type] absolute_path = File.expand_path(relative_path) - info message: "Loading #{config_type.to_s} from #{absolute_path}" + info message: "Loading #{config_type} from #{absolute_path}" data = YAML.load(File.read(absolute_path)) configatron[config_type].configure_from_hash(data) rescue => ex - exception "Couldn't load #{config_type.to_s} from #{absolute_path}", ex + exception "Couldn't load #{config_type} from #{absolute_path}", ex end def log_line(section, options = {}) options = { message: options } if options.is_a?(String) tag = tag(options) @@ -79,28 +75,26 @@ else formated_section end end def tag(options) - tag = '' - if options['workflow_id'] && options['instance_id'] - tag = "[#{options['workflow_id']}:#{options['instance_id']}]" - elsif options['workflow_id'] && !options['instance_id'] - tag = "[#{options['workflow_id']}]" - elsif !options['workflow_id'] && options['instance_id'] - tag = "[#{options['instance_id']}]" - end - tag + primary = options['service_id'] || options['instance_id'] + secondary = if options['service_id'] && options['instance_id'] + ":#{options['instane_id']}" + else + '' + end + primary ? "[#{primary}#{secondary}]" : '' end def time - Time.now.localtime.strftime('%m/%d/%y %T.%L') + Time.now.localtime.strftime('%m/%d/%y %T.%L') end def write(message) stream = @destination_stream || $stdout stream.puts(message) stream.flush end end end -end \ No newline at end of file +end