class InstagramCrawler::Logger

Public Class Methods

info(str) click to toggle source
# File lib/instagram_crawler/logger.rb, line 15
def info(str)
  @logger.info(str)
end
setting(log) click to toggle source
# File lib/instagram_crawler/logger.rb, line 4
def setting(log)
  io = [STDOUT]
  io << log_file if log
  logger = Logger.new(MultiIO.new(*io))
  logger.level = Logger::INFO
  logger.formatter = proc do |_severity, _datetime, _progname, msg|
    "#{msg}\n"
  end
  @logger = logger
end

Private Class Methods

log_file() click to toggle source
# File lib/instagram_crawler/logger.rb, line 21
def log_file
  time = Time.now.strftime('%Y-%m-%dT%H:%M:%S')
  FileUtils.mkdir_p(Config.log_path) unless Dir.exist?(Config.log_path)
  log_file = File.open("#{Config.log_path}/#{time}.txt", 'a')
  log_file
end