Class: HP::Cloud::Log

Inherits:
Object
  • Object
show all
Defined in:
lib/hpcloud/log.rb

Instance Method Summary collapse

Constructor Details

#initialize(shell) ⇒ Log

Returns a new instance of Log.



25
26
27
28
# File 'lib/hpcloud/log.rb', line 25

def initialize(shell)
  @silence_display = nil
  @shell = shell
end

Instance Method Details

#display(message) ⇒ Object



50
51
52
# File 'lib/hpcloud/log.rb', line 50

def display(message)
  @shell.say message unless @silence_display
end

#error(err, exit_status = :general_error) ⇒ Object



35
36
37
38
39
40
41
42
43
44
45
46
47
48
# File 'lib/hpcloud/log.rb', line 35

def error(err, exit_status = :general_error)
  if err.kind_of?(String)
    message = err
  else
    if err.kind_of?(CliStatus)
      exit_status = err.error_code
      message = err.to_s
    else
      message = ErrorResponse.new(err).to_s
    end
  end
  $stderr.puts message
  @shell.exit_status.set(exit_status)
end

#fatal(err, exit_status = :general_error) ⇒ Object



30
31
32
33
# File 'lib/hpcloud/log.rb', line 30

def fatal(err, exit_status = :general_error)
  error(err, exit_status)
  exit @shell.exit_status.get
end