module Modsvaskr::Logger

Mixin adding logging functionality, both on screen and in file

Attributes

log_file[RW]
stdout_io[RW]

Public Instance Methods

log(msg) click to toggle source

Log on screen and in log file

Parameters
  • msg (String): Message to log

# File lib/modsvaskr/logger.rb, line 18
def log(msg)
  complete_msg = "[ #{Time.now.strftime('%F %T')} ] - [ #{self.class.name.split('::').last} ] - #{msg}"
  Logger.stdout_io << "#{complete_msg}\n"
  File.open(Logger.log_file, 'a') do |f|
    f.puts complete_msg
  end
end
out(msg) click to toggle source

Display an output to the user. This is not a log.

Parameters
  • msg (String): Message to output

# File lib/modsvaskr/logger.rb, line 31
def out(msg)
  Logger.stdout_io << "#{msg}\n"
end
wait_for_user_enter() click to toggle source

Wait for the user to enter a line and hit Enter

Result
  • String: The line entered by the user

# File lib/modsvaskr/logger.rb, line 39
def wait_for_user_enter
  @config.no_prompt ? "\n" : $stdin.gets
end