class Wordmove::Logger

Constants

MAX_LINE

Public Class Methods

new(device, strings_to_hide = []) click to toggle source
Calls superclass method
# File lib/wordmove/logger.rb, line 5
def initialize(device, strings_to_hide = [])
  super(device, formatter: proc { |_severity, _datetime, _progname, message|
    formatted_message = if strings_to_hide.empty?
                          message
                        else
                          message.gsub(
                            Regexp.new(
                              strings_to_hide.map { |string| Regexp.escape(string) }.join('|')
                            ),
                            '[secret]'
                          )
                        end

    "\n#{formatted_message}\n"
  })
end

Public Instance Methods

debug(message) click to toggle source
# File lib/wordmove/logger.rb, line 45
def debug(message)
  add(DEBUG, "    🛠  debug".magenta + " | ".black + message.to_s)
end
error(message) click to toggle source
# File lib/wordmove/logger.rb, line 37
def error(message)
  add(ERROR, "    ❌  error".red + " | ".black + message.to_s)
end
info(message) click to toggle source
# File lib/wordmove/logger.rb, line 53
def info(message)
  add(INFO, "    ℹ️  info".yellow + " | ".black + message.to_s)
end
plain(message) click to toggle source
# File lib/wordmove/logger.rb, line 57
def plain(message)
  add(INFO, message.to_s)
end
success(message) click to toggle source
# File lib/wordmove/logger.rb, line 41
def success(message)
  add(INFO, "    ✅  success".green + " | ".black + message.to_s)
end
task(title) click to toggle source
# File lib/wordmove/logger.rb, line 22
def task(title)
  prefix = "▬" * 2
  title = " #{title} "
  padding = "▬" * padding_length(title)
  add(INFO, prefix + title.light_white + padding)
end
task_step(local_step, title) click to toggle source
# File lib/wordmove/logger.rb, line 29
def task_step(local_step, title)
  if local_step
    add(INFO, "    local".cyan + " | ".black + title.to_s)
  else
    add(INFO, "   remote".yellow + " | ".black + title.to_s)
  end
end
warn(message) click to toggle source
# File lib/wordmove/logger.rb, line 49
def warn(message)
  add(WARN, "    ⚠️  warning".yellow + " | ".black + message.to_s)
end

Private Instance Methods

padding_length(line) click to toggle source
# File lib/wordmove/logger.rb, line 63
def padding_length(line)
  result = MAX_LINE - line.length
  result.positive? ? result : 0
end