Module: HolePunch::Logger

Defined in:
lib/holepunch/logger.rb

Class Attribute Summary collapse

Class Method Summary collapse

Class Attribute Details

.outputObject

Returns the value of attribute output.



35
36
37
# File 'lib/holepunch/logger.rb', line 35

def output
  @output
end

.verboseObject

Returns the value of attribute verbose.



34
35
36
# File 'lib/holepunch/logger.rb', line 34

def verbose
  @verbose
end

Class Method Details

.fatal(msg, exit_code = 1) ⇒ Object



47
48
49
50
51
# File 'lib/holepunch/logger.rb', line 47

def fatal(msg, exit_code = 1)
  return if output.nil?
  output.fatal("ERROR: #{msg}")
  exit(exit_code)
end

.log(prefix, msg = nil) ⇒ Object



37
38
39
40
41
42
43
44
45
# File 'lib/holepunch/logger.rb', line 37

def log(prefix, msg = nil)
  return unless verbose
  return if output.nil?
  if msg.nil?
    output.log prefix
  else
    output.log "#{prefix.to_s.rjust(12)} #{msg}"
  end
end