Class: Machines::Logger

Inherits:
Object
  • Object
show all
Defined in:
lib/machines/logger.rb

Instance Method Summary collapse

Constructor Details

#initialize(to, options = {}) ⇒ Logger

Returns a new instance of Logger.



13
14
15
16
# File 'lib/machines/logger.rb', line 13

def initialize to, options = {}
  @to = to
  @truncate = options[:truncate]
end

Instance Method Details

#flushObject



29
30
31
# File 'lib/machines/logger.rb', line 29

def flush
  @to.flush
end

#log(message, options = {}) ⇒ Object

Logs a message

Parameters:

  • message (String)

    Message to display

  • options (Hash) (defaults to: {})

Options Hash (options):

  • :progress (String)

    Prepends number of commands completed

  • :color (String)

    Color the text (overrides :success)

  • :newline (Bool)

    Set to false to print on same line and return to start of it (:color not supported)



24
25
26
27
# File 'lib/machines/logger.rb', line 24

def log message, options = {}
  message = format_message(message, options)
  @to.print message
end