Class: IO

Inherits:
Object
  • Object
show all
Defined in:
lib/react_native_util/core_ext/io.rb

Overview

Logging extensions to the IO class

Instance Method Summary collapse

Instance Method Details

#log(message, obfuscate: true) ⇒ Object

Logs a message with obfuscation and a timestamp.

Parameters:

  • message (#to_s)

    A message to log. Will be converted to a String and obfuscated.

  • obfuscate (true, false) (defaults to: true)

    Obfuscate the message to be logged

Returns:

  • nil

See Also:



13
14
15
16
# File 'lib/react_native_util/core_ext/io.rb', line 13

def log(message, obfuscate: true)
  message = message.to_s.obfuscate if obfuscate
  puts "#{DateTime.now} #{message}"
end

#log_command(command) ⇒ Object

Logs a command to be executed by a call such as Kernel#system. If the command parameter is an Array, it will be joined using Array#shelljoin from shellwords. Otherwise it will be interpolated in a String.

Parameters:

  • command (Array, #to_s)

    A command to be logged

Returns:

  • nil



25
26
27
28
29
30
# File 'lib/react_native_util/core_ext/io.rb', line 25

def log_command(command)
  string_to_log = (command.kind_of?(Array) ? command.shelljoin : command)
  log "$ #{string_to_log}".cyan.bold
  flush
  nil
end