class IO

Logging extensions to the IO class

Public Instance Methods

log(message, obfuscate: true) click to toggle source

Logs a message with obfuscation and a timestamp. @see String#obfuscate!

@param message [#to_s] A message to log. Will be converted to a String and obfuscated. @param obfuscate [true, false] Obfuscate the message to be logged @return nil

# File lib/react_native_util/core_ext/io.rb, line 14
def log(message, obfuscate: true)
  message = message.to_s.obfuscate if obfuscate
  puts "#{DateTime.now} #{message}"
end
log_command(command) click to toggle source

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.

@param command [Array, to_s] A command to be logged @return nil

# File lib/react_native_util/core_ext/io.rb, line 26
def log_command(command)
  string_to_log = (command.kind_of?(Array) ? command.shelljoin : command)
  log "$ #{string_to_log}".cyan.bold
  flush
  nil
end